【发布时间】:2010-09-18 06:50:50
【问题描述】:
考虑下面的代码sn-p
private void ProcessFile(string fullPath) {
XmlTextReader rdr = new XmlTextReader("file:\\\\" + fullPath);
while (rdr.Read()) {
//Do something
}
return;
}
现在,当传递如下路径时,此功能正常:
"C:\Work Files\Technical Information\Dummy.xml"
但是通过的时候会报错
"C:\Work Files\#Technical Information\Dummy.xml"
请注意,指定的所有文件夹和文件都存在,并且哈希字符是路径的有效字符。错误详情如下:
System.IO.DirectoryNotFoundException:找不到路径“C:\Work Files\”的一部分。
在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
在 System.IO.FileStream.Init(字符串路径,FileMode 模式,FileAccess 访问,Int32 权限,布尔用户权限,FileShare 共享,Int32 缓冲区大小,FileOptions 选项,SECURITY_ATTRIBUTES secAttrs,字符串 msgPath,布尔 bFromProxy)
在 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
在 System.Xml.XmlDownloadManager.GetStream(Uri uri,ICredentials 凭据)
System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
在 System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver)
在 System.Threading.CompressedStack.runTryCode(Object userData)
在 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode 代码,CleanupCode backoutCode,对象 userData)
在 System.Threading.CompressedStack.Run(CompressedStack 压缩堆栈,ContextCallback 回调,对象状态)
在 System.Xml.XmlTextReaderImpl.OpenUrl()
在 System.Xml.XmlTextReaderImpl.Read()
在 System.Xml.XmlTextReader.Read()
有人知道怎么回事吗?
【问题讨论】:
标签: c# .net xmltextreader