C# XML - Reading Included XML Document

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

Answers


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.


Need Your Help

SEO - How does crawler handle domainname itsself?

web-crawler seo google-crawlers

I am planning to grab a domain for a new web project. I'm not a SEO-pro but I know some stuff about SEO, HIT and Page Rank algorithms and did some research on domain names and their role in SEO, to...

Coordinate Points to Polygons

algorithm google-maps gis polygon

I have a large set of coordinates, which include the likes of:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.