【发布时间】:2014-05-14 08:00:27
【问题描述】:
我想使用 ASP.NET 上传 1 GB 的文件。我写这段代码
Dim bytes(up_FileImage.UploadedFiles(0).ContentLength) As Byte
bytes = File.ReadAllBytes(Path.Combine(Request.PhysicalApplicationPath, "App_Data/", ViewState("DirectoreName").ToString(), up_FileImage.UploadedFiles(0).FileName))
itemDocFile.FileImage = bytes
并在 web.config 中编写此代码
<httpRuntime maxRequestLength="102400" executionTimeout="3600"/>
但是在第一行我得到了这个错误
system.out of memory exception
请帮助我。谢谢大家
【问题讨论】:
-
IIS默认大小只有4MB,所以上传1GB大小的文件会报错,尝试从webconfig文件中设置文件大小。
-
@Krunal Patil:我更新了问题。谢谢。
-
File.ReadAllBytes() 意味着您会将所有内容加载到内存中。如果可以的话,尽量避免这种情况。
标签: asp.net vb.net telerik radupload