I have created a basic project in to which i have added a really simple xml file. I can see the file and my one form in the project solution. I am trying to write code to read the xml file but i cant seem to access it as visual studio doesnt seem to be picking up that its there if that makes sense? How do i get at that file so i can do something like
XmlDocument doc = new XmlDocument();
doc.Load("My document here")
Thanks
You mean you added the xml-file to the solution? If so, you need to edit the properties of the xml-file (right click in solution-explorer and select properties), and set it to always copy on build. This will copy the xml-file to the bin/Debug-folder when you build, and this is where the program is run from. If not you need to change the file-path to “../../filename.xml”, this will also work.
Note:
This is only a solution to your problem if the xml-file is part of the solution, and the program doesn’t find the file when you run it. And you must not be using absolute paths.