我需要在不缓冲到内存的情况下将文件传输到客户端,所以我使用了Response.TransmitFile,但是这个函数抛出了PathTooLongException,我可以在IO.File函数中处理这个异常,但是我没有为这个TransmitFile找到任何解决方案,堆栈跟踪就像炸掉了一样
Message :The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
StackTrace : at System.IO.PathHelper.GetFullPathName()
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.Web.HttpResponse.TransmitFile(String filename, Int64 offset, Int64 length)
at _Default.Page_Load(Object sender, EventArgs e) in Download.aspx.cs:line 151
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)发布于 2015-05-10 05:29:42
你真的需要阅读这个错误:
消息:指定的路径、文件名或两者都太长。完全限定文件名必须少于260个字符,目录名必须少于248个字符。
问题是什么真的很清楚。我猜你的路径或文件名太长了。
检查您在以下位置传输的文件名:
at System.Web.HttpResponse.TransmitFile(String filename, Int64 offset, Int64 length)
at _Default.Page_Load(Object sender, EventArgs e) in c:\Inetpub\dl1.isdm.ir\Download.aspx.cs:line 151https://stackoverflow.com/questions/30144453
复制相似问题