让文本文件也能下载!
[ 2007-7-19 17:54:00 | By: 99love ]
文本文件浏览器能够识别,点击它的时候它会直接在浏览器中打开
但有时候我们不需要这样做,我们需要下载它,于是就可以这样:
string DownloadFilePath ="c:\\file.txt";
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=file.txt" );
Response.Flush();
Response.WriteFile(DownloadFilePath);
Response.End();
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=file.txt" );
Response.Flush();
Response.WriteFile(DownloadFilePath);
Response.End();

Re:让文本文件也能下载!
[ 2007-7-20 11:06:00 | By: birder ]




