I have created an XML file in my solution path. My solution has multiple projects (one of them is a service), now some of these projects need to refer to the XML file
-
When I try and use
XDocument configXML = new XDocument.Load("Config.xml");
I get an error
Cannot find symbol ‘Load’
I am using System.Xml.Linq
-
Because I was unable to get around problem 1, i tried
XElement rootElement = XElement.Load("Config.xml");
this worked, but when I run the program, i get an error:
Unable to find the xml file
since it is searching in the ../Release folder, who can I copy the xml file to the release/debug/deployed folders?
Need some assistance!
Load is a static method, you don’t need an instance:
If you want the Config.xml file to be automatically copied to the output directory you could select it in the solution explorer and set its Copy to Output Directory property: