[英]Can't download file larger than 2 gb in MVC
我想下载一个zip文件,但大小超过2 GB。 由于byte []数组中2 GB大小的限制,我遇到了一个问题。 如何下载zip文件?
FileContentResult fileContent = new
FileContentResult(System.IO.File.ReadAllBytes(exportDirectoryZip),
"application/zip")
{
FileDownloadName = Path.GetFileName(exportDirectoryZip)
};
//FOR VIEWS
var cd = new System.Net.Mime.ContentDisposition
{
Inline = true,
FileName = fileContent.FileDownloadName
};
//Response.AddHeader("Content-Disposition", cd.ToString());
return File(fileContent.FileContents, "application/zip");
将大文件(特别是2GB)加载到仅以流形式传输到客户端的内存中,效率很低,更不用说在32位进程中遇到内存问题。 您最好加载要进行流传输的文件并返回流。 这样可以降低主机对内存的影响。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.