I am trying to write a chunk of XML data to a file like this:
using (XmlWriter writer = XmlWriter.Create("D://project//data//" + i + ".xml"))
but it gives the following error:
Server Error in ‘/’ Application.
Could not find a part of the path ‘
D:\project\data\1.xml‘.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:
System.IO.DirectoryNotFoundException: Could not
find a part of the path ‘D:\project\data\1.xml‘.
However, when I am reading an XML using an XmlReader:
XmlReader reader = XmlReader.Create("d://project//data.xml");
it creates the reader seamlessly and gives no error. I don’t understand why.
EDIT: sorry both the folder paths are same and the correct one is d://project//data.xml
I’ve spotted two things that are wrong here.
and
The top
Createuses a directory calledproject_elysianand the second is usingproject.Also, you are creating a file called
data.xmland the other you are usingdataas a directory. If you are looking at incrementing the file, then you will need to remove the foward slash before theivariable