I am trying to check whether XmlTextReader reads the xml file
successfully or not.
MSDN says that XmlTextReader raise the FileNotFoundException when it
cannot find the file to read.
Here is the source code I wrote.
string fileName = "thisfileneverexist.xml";
XmlTextReader xmlReader = null;
try
{
xmlReader = new XmlTextReader(fileName); // <---- this file does
not exist.
}
catch(Exception e)
{
// so, FileNotFoundException should be caught up here.
}
But the result is not what I expected because FileNotFoundException is
never raised.
So, how can i check XmlTextReader reads the xml file successfully?
Please help!!