vicky vicky - 1 year ago 63
C# Question

Unable to load XML file in windows app

I am trying to load an xml file in windows app and not able to do it.

The actual path of the file is

and when I try to get them using the below mentioned code, it gives this error
Additional information: Could not find file 'C:\Users\Desktop\Apps\Panel\Panel\bin\Debug\Info.xml'.

XDocument doc = XDocument.Load("Info.xml");

Which means
is added to the path additionally. Could anyone tell me how it got added and can be removed.

Answer Source

This is because the file is located in your project, not in your Debug directory. Write it this way.

XDocument doc = XDocument.Load("../../UserLoginInfo.xml");

If you want to work your way click properties on UserLoginInfo.xml in your project and select Copy to output directory

\bin\Debug\ is added because this is the directory where your app is started.