strOutputFileName=@"C:\1.txt";
string filename = strOutputFileName.Substring(strOutputFileName.LastIndexOf('\\'), strOutputFileName.Length - strOutputFileName.LastIndexOf('\\'));
Response.Clear();
Response.ContentType = "application/x-zip-compressed";
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8));
Response.TransmitFile(strOutputFileName);
ApplicationInstance.CompleteRequest();
但下载文件后,发现连网页上的HTML都在文件里面了,
文件原来的内容后面加上当前网页的HMTL,请问怎么实现TXT下载呢?
Response.TransmitFile(strOutputFileName);
Response.End();
"application/x-zip-compressed" ? ContentType设置 不正确吧?
txt 文档? 可以统一使用 application/oct-stream