亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

System.OutOfMemoryException ,簡化代碼如下,有沒有解決辦法?

System.OutOfMemoryException ,簡化代碼如下,有沒有解決辦法?

阿波羅的戰車 2018-07-27 09:10:46
public partial class _Default : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){byte[] bytes = File.ReadAllBytes("D:\toClient.xls");//toClient.xls 大小為20MResponse.BinaryWrite(bytes);}}運行后直接報:System.OutOfMemoryException 
查看完整描述

2 回答

?
開心每一天1111

TA貢獻1836條經驗 獲得超13個贊

一般是這么寫:

Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(downloadName, System.Text.Encoding.UTF8));
Response.WriteFile("D:\toClient.xls");
Response.Flush();
Response.End();


查看完整回答
反對 回復 2018-07-30
?
鳳凰求蠱

TA貢獻1825條經驗 獲得超4個贊

不要直接Response.BinaryWrite(bytes);

每次讀取一個  byte[]

然后Response.Flush();

 


查看完整回答
反對 回復 2018-07-30
  • 2 回答
  • 0 關注
  • 720 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號