我想XML数据块写入到这样的文件:为什么XmlWriter在此代码中引发错误?
using (XmlWriter writer = XmlWriter.Create("D://project//data//" + i + ".xml"))
,但它提供了以下错误:
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
'.
然而,当我读使用XmlReader
的XML :
XmlReader reader = XmlReader.Create("d://project//data.xml");
它创造了读者无缝,并没有错误。我不明白为什么。
编辑:对不起这两个文件夹的路径是相同的,正确的是d://project//data.xml
这些文件夹是不同的。可能d:// project_elysian /存在,而D://项目//数据//不存在。 – 2012-02-09 09:52:01
你的问题似乎清除异常:目录不存在, – Schwarzie2478 2012-02-09 09:53:23