.NET 按格式导出txt

 

后台代码

        private void DownTxt()
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < 50000; i++)
                {
                    sb.Append("测试i=" + i+"\r\n");
                }
                Response.Clear();
                Response.Headers["Content-Disposition"] = "attachment;filename=aaa.txt";//输出文件格式
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); //解决乱码问题
                Response.Write(sb.ToString());
            }
            catch (Exception EX)
            {
                throw EX;
            }
        }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2021-08-27
  • 2022-12-23
  • 2022-12-23
  • 2022-01-17
猜你喜欢
  • 2021-11-15
  • 2021-12-04
  • 2021-07-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
相关资源
相似解决方案