转换成流字节,输出浏览器下载

//转换成流字节,输出浏览器下载
var byti = file.SaveToStream().GetBuffer();
////通知浏览器保存文件,其实也就是输出到浏览器
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + filename);
Response.BinaryWrite(byti);
Response.Flush();
Response.Close();

原文地址:https://www.cnblogs.com/sntetwt/p/6244063.html