Reputation: 825
I added a xml file into my solution in a windows application. but when i am executing the below code it is not finding the xml.
var xDoc = XDocument.Load("Services.xml");
It is giving exception that this xml is not found inside bin/debug\folder.
Can anybody help me on this..?
Upvotes: 0
Views: 563
Reputation: 6251
Use:-
var xDoc = XDocument.Load(Application.StartupPath + "\Services.xml");
Apart from that make sure: -
Upvotes: 1
Reputation: 310
As others have mentioned, this is because your XML file is not being copied to your bin/Debug folder.
If your XML file is included in your project folder and you want it to copy over automatically whenever you debug or build, then right click on it within the Solution Explorer and goto Properties. From the Properties menu, set Build Action to "Content" and Copy to Output Directory to "Copy if newer".
Let me know if this doesn't work.
Upvotes: 0