XML : How can I access an XML file in the root project directory in Visual Studio?

This seems like an extremely simple thing to do, but I have not been able to find an answer to my question specifically. I have an ASP.NET website project, and I'm trying to simply load an XML file to process some data. See the code below.

  var XmlData = XDocument.Load("TheXMLFile.xml");    

This line of code is giving me the following error: System.IO.FileNotFoundException was unhandled by user code Message=Could not find file 'C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\TheXMLFile.xml'. First of all, the path given above isn't even where the file is anyway. The project file structure looks like this:

  MyProject      .      .      .       TheXMLFile    

I am clueless as to why it can't find the file. Any suggestions?

No comments:

Post a Comment