XmlTextReader and file detection...

garcon

Well-known member
Joined
Dec 13, 2004
Messages
47
Programming Experience
Beginner
Folks,

I'm bulletproofing. I'm using "XmlTextReader" to open and parse an XML file. This is working fine and dandy as show below:

VB.NET:
[size=2][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] fxRatesFile [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Xml.XmlTextReader[/size][size=2]
[/size][size=2][color=#008000][/color][/size] 
[size=2][color=#008000]'Create the XML Reader[/color][/size]
[size=2][color=#008000][size=2]fxRatesFile = [/size][size=2][color=#0000ff]New[/color][/size][size=2] System.Xml.XmlTextReader("C:\a.xml")
[/size][/color][/size]

I'm now bullet proofing. I don't like the way that the code above does not count for the possibity that "a.xml" mat not be there. Can anyone out there help me with this possibility i.e. is it possible to first detect if "a.xml" is present and if not throw a suitable error message?

Comments/suggestions/ideas/code-samples greatly appreciated,
Thank you,
G.
 
Sure use :

VB.NET:
if system.io.file.exists("c:\a.xml") then
.....
End if
[\code]
 
TPM
 
Back
Top