XmlDocument.Load xml file failed

3.2k views Asked by At

Just try to load an xml file in C#, but keep getting an exception.

Here are the code:

XmlDocument xDoc = new XmlDocument();
xDoc.Load(@"C:\test.XML");

Here is the error message:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in System.Xml.dll Additional information: Could not find file 'C:\ndentity.ent'.

I tried to move the xml file around on my local machine, but keep getting the error like "Could not find file '...\ndentity.ent'. Am I missing anything?

Thank you in advance.

1

There are 1 answers

3
Alioza On

Try this:

 XmlDocument doc = new XmlDocument();
  doc.LoadXml(File.ReadAllText(@"C:\test.XML"));