/// <summary>
        /// 下载附件方法
        /// </summary>
        private void DownLoad()
        {
            Response.Expires = -1;
            string filename = Guid.NewGuid().ToString() + ".txt";
            filename = Server.MapPath(filename);
            StreamWriter write = new StreamWriter(filename, true, System.Text.Encoding.UTF8);
            write.WriteLine(this.txtException.Text);
            write.Flush();
            write.Close();

            Response.Clear();
            Response.ClearHeaders();
            //Response.Buffer = false;
            System.IO.FileInfo fi = new FileInfo(filename);
            Response.ContentType = "application/octet-stream";
            Response.AppendHeader("Content-Disposition", "attachment;filename= " + HttpUtility.UrlEncode(fi.FullName, System.Text.Encoding.UTF8));
            Response.AppendHeader("Content-Length ", fi.Length.ToString());
            Response.WriteFile(fi.FullName);
            Response.Flush();
            System.IO.File.Delete(filename);
            Response.End();
        }

相关文章:

  • 2022-12-23
  • 2021-09-01
  • 2021-06-19
  • 2021-08-03
  • 2022-01-14
  • 2021-11-23
  • 2022-02-12
猜你喜欢
  • 2022-12-23
  • 2021-06-01
  • 2021-10-26
  • 2022-02-08
  • 2022-02-27
  • 2021-10-27
  • 2022-12-23
相关资源
相似解决方案