private void Download(string fileName, byte[] buffer)
{
Response.ContentType = "application/octet-stream";
//通知浏览器下载文件而不是打开
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
Response.AddHeader("Content-Length", buffer.Length.ToString());
Response.BinaryWrite(buffer);
Response.Flush();
//Response.End();
}
转载于:https://www.cnblogs.com/zhongjy001/archive/2009/10/16/1584491.html