首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Response.TransmitFile抛出PathTooLongException

使用Response.TransmitFile抛出PathTooLongException
EN

Stack Overflow用户
提问于 2015-05-10 04:03:32
回答 1查看 174关注 0票数 0

我需要在不缓冲到内存的情况下将文件传输到客户端,所以我使用了Response.TransmitFile,但是这个函数抛出了PathTooLongException,我可以在IO.File函数中处理这个异常,但是我没有为这个TransmitFile找到任何解决方案,堆栈跟踪就像炸掉了一样

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

发布于 2015-05-10 05:29:42

你真的需要阅读这个错误:

消息:指定的路径、文件名或两者都太长。完全限定文件名必须少于260个字符,目录名必须少于248个字符。

问题是什么真的很清楚。我猜你的路径或文件名太长了。

检查您在以下位置传输的文件名:

代码语言:javascript
复制
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 151
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30144453

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档