private void DownLoad(string fileName, string path)
        {
            FileInfo fi = new FileInfo(path);

            if (fi.Exists)
            {
                Response.Clear();
                Response.ClearContent();
                Response.ClearHeaders();
                Response.Buffer = true;

                Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
                Response.AddHeader("Content-Length", fi.Length.ToString());
                Response.AddHeader("Content-Transfer-Encoding", "binary");
                Response.ContentType = "application/octet-stream";
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");

                Response.WriteFile(path);
                Response.Flush();
                Response.End();
            }
        }

        private void DownLoad2(string fileName, string path)
        {
            FileInfo fi = new FileInfo(path);

            if (fi.Exists)
            {
                Response.Clear();
                Response.Buffer = true;

                Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
                Response.ContentType = "application/unknow";

                Response.TransmitFile(path);
                Response.End();
            }
        }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-14
  • 2021-11-09
  • 2022-12-23
  • 2021-09-08
  • 2021-09-08
猜你喜欢
  • 2021-09-30
  • 2021-11-03
  • 2021-08-14
  • 2021-05-13
  • 2021-12-30
  • 2021-10-25
  • 2021-12-11
相关资源
相似解决方案