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) != -1)
                {
                    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();
            }
        }

 

相关文章:

  • 2021-12-29
  • 2022-12-23
  • 2022-12-23
  • 2021-05-06
  • 2022-12-23
  • 2021-10-11
  • 2021-06-01
  • 2021-09-02
猜你喜欢
  • 2022-12-23
  • 2021-10-12
  • 2022-12-23
  • 2021-11-04
  • 2021-07-21
  • 2021-12-13
  • 2022-12-23
相关资源
相似解决方案