【发布时间】:2014-05-22 02:55:45
【问题描述】:
有没有办法从 UNC 路径获取本地路径?
例如:\\server7\hello.jpg 应该给我 D:\attachments\hello.jpg
在应用 Windows 文件名和完整路径长度限制后,我正在尝试将附件保存到 UNC 路径。在这里,我通过以 UNC 路径长度为参考来应用这些限制。但是本地路径长度比 UNC 路径长,我认为因此我得到了以下异常。
System.IO.PathTooLongException 发生 HResult=-2147024690
Message=指定的路径、文件名或两者都太长。完全 限定文件名必须少于 260 个字符,并且 目录名称必须少于 248 个字符。来源=mscorlib
堆栈跟踪: 在 System.IO.PathHelper.GetFullPathName() 在 System.IO.Path.NormalizePath(字符串路径,布尔 fullCheck,Int32 maxPathLength,布尔 expandShortPaths) 在 System.IO.Path.NormalizePath(字符串路径,布尔 fullCheck,Int32 maxPathLength) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize,FileOptions 选项,SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean 检查主机) 在 System.IO.FileStream..ctor(字符串路径、FileMode 模式、FileAccess 访问、FileShare 共享、Int32 bufferSize、FileOptions 选项,字符串 msgPath,布尔 bFromProxy) 在 System.IO.FileStream..ctor(字符串路径,FileMode 模式) 在 Presensoft.JournalEmailVerification.EmailVerification.DownloadFailedAttachments(EmailMessage msg, JournalEmail journalEmail) 在 D:\Source\ProductionReleases\Release_8.0.7.0\Email 存档\Presensoft.JournalEmailVerification\EmailVerification.cs:line 630 内部异常:
【问题讨论】: