I am in trouble, so need some help. I have my file stored in the following path-->
H:\Testapps\appz\Sampl开发者_如何学Pythone1\Sample1\Data.xml
I am trying to load the xml file in an XMLDOCUMENT like this -->
XMLDocument xdoc=new XMLDocument();
string xmlfile = "..\Sample1\Data.xml";
xdoc.Load(xmlfile);
I get an error -
Could not find a part of the path 'H:\Testapps\appz\Sample1\Sample1\bin\Debug\Sample1\Sample1\RemData.xml'.
How do i proceed in specifying the xmlfile path?? Any help appreciated!
Another problem i am facing is when i try to write new node in an existing xml file by providing just the name of the xml file, i do not see contents saved in the xml file.
But if i provide the complete path for the xml file, the data gets saved in the aml file.
I am using
xdoc.Save("RemData.xml");
I want a partial file path rather than H:\Testapps\appz\Sample1\Sample1\bin\Debug\Sample1\Sample1\RemData.xml
but how?
You are using a relative path. Doing so means that you're telling the application to use the executable's directory as the "root path". What you probably want is to automatically have the XML files copied to the output directory. To do this, I usually set the "Build Action" property for the XML file to "Embedded Resource" and set "Copy to Output Directory" to "Copy Always". Hope this helps.
BTW, you might also want to take a look at Pack URI's.
精彩评论