public static void DownFileStream(MemoryStream ms, string fileName)
{
if (ms !=Stream.Null)
{ if (HttpContext.Current.Request.UserAgent != null && HttpContext.Current.Request.UserAgent.ToUpper().IndexOf("FIREFOX", StringComparison.Ordinal) != -)
{
fileName = "=?UTF-8?B?" + Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(fileName)) + "?=";
}
else
{
fileName = System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8);
if (fileName != null) fileName = fileName.Replace("+", "%20");
}
HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}.xls",fileName));
HttpContext.Current.Response.AddHeader("Content-Length", ms.Length.ToString());
HttpContext.Current.Response.AddHeader("Content-Transfer-Encoding", "binary");
HttpContext.Current.Response.ContentType = "application/octet-stream;charset=utf-8";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
HttpContext.Current.Response.BinaryWrite(ms.ToArray());
ms.Close();
ms.Dispose();
}
}

最新文章

  1. 锐捷与Vmare网络冲突解决办法
  2. spring 的IoC的个人理解
  3. codeforces gym 100694 M The Fifth Season (巴什博奕)
  4. java多线程-Condition
  5. SVN更新、清理乱码解决
  6. 用VBS脚本发邮件
  7. javaWeb中的/路径问题
  8. [AngularJS] Services, Factories, and Providers -- Service vs Factory
  9. C# 开机自动启动程序
  10. Windsock套接字I/O模型学习 --- 第一章
  11. SQLSERVER设置行号
  12. Django学习(四)---Admin配置
  13. Myeclipse 配置Tomcat 出现 “Value must be an existing directory”错误
  14. HttpClient4.2 Fluent API学习
  15. 用C语言绘制一条标准的余弦曲线
  16. 微信小程序-制作简易豆瓣笔记
  17. MySQL数据库之安装
  18. 如何使QLineEdit禁止编辑
  19. a 超链接标签
  20. Eclipse编辑JS响应慢,复制粘贴卡顿的解决方案

热门文章

  1. django 补充篇
  2. py-faster-rcnn之python引入_caffe.so
  3. 架构师养成记--9.future模式讲解
  4. JAVA发展史
  5. ParamTest
  6. Tengine 安装配置全过程
  7. zabbix监控Java 8080端口
  8. 深入理解javascript原型和闭包 (转)
  9. Money, save or spend, this is a problem .
  10. SqlServer 常用函数