if i want to add a file to a project in c#, i just right click the project, add a new xml file and then always set to copy to the output directory. That way when the user runs it there will always be a copy of it.
Now i want to logically group 4 xml files with a folder. I added the folder, added the xml files to the folder, and set to copy. Thats great in the sense that it copies the folder to the output directory. But now however, instead of being able to open the xml file like this
XmlDocument doc = new XmlDocument();
doc.Load(filename);
i n开发者_如何学编程eed a new way of doing it as it doesnt locate the xml file as its within the folder in the output directory, opposed to directly in the output directory if that makes sense?
what can i do?
Thanks
Adding this as an answer:
doc.Load(Path.Combine("MyFolder", filename));
You could set it as an embedded resource and access it that way. Have a look at this link
http://support.microsoft.com/kb/319292
精彩评论