【问题标题】:FileUpload.FileBytes get OutOfMemoryExceptionFileUpload.FileBytes 得到 OutOfMemoryException
【发布时间】:2017-07-05 13:22:41
【问题描述】:

我使用 FileUpload 组件。我添加了大约 120mb 的文件。但是当文件大小增加时,FileBytes 会报错OutOfMemoryException

FileBytes 返回字节[]。

我的代码:

   byte[] byt = new byte[0];
    byt = FileUpload1.FileBytes;

我需要获取文件并转换字节数组,或者我可以使用 js。 我必须得到文件。但我采用文件路径。返回值为 c:/fakepath.... 是错误的。

有什么解决办法吗?

【问题讨论】:

标签: c# out-of-memory


【解决方案1】:

在您的 web.config 中,您有两个参数来处理这个问题:

<system.web>
    <httpRuntime maxRequestLength="X" executionTimeout="Y"/>  
</system.web>

(X 以千字节为单位,Y 以秒为单位)

<system.webServer> 
     <security> 
          <requestFiltering> 
             <requestLimits maxAllowedContentLength="Z" /> 
          </requestFiltering> 
     </security> 
</system.webServer>

(Z 字节)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-25
    • 2014-11-14
    • 1970-01-01
    • 2013-05-09
    • 1970-01-01
    • 1970-01-01
    • 2014-08-10
    相关资源
    最近更新 更多