[英]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.