文本文件浏览器能够识别,点击它的时候它会直接在浏览器中打开 但有时候我们不需要这样做,我们需要下载它,于是就可以这样:
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();
|
让文本文件也能下载!
最新推荐文章于 2023-03-05 15:07:52 发布