动态生成TXT文件供下载

 

  
  
  
  
  1. string FileName = "FileName"
  2. Response.ContentType = "Application/octet-stream"
  3. Response.AppendHeader("Content-Disposition""attachment;filename=\"" + System.Web.HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8) + ".txt\""); 
  4. HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8"); 
  5. Response.Write("文本内容"); 
  6. Response.Flush(); 
  7. Response.End(); 

 

你可能感兴趣的:(下载,txt)