private void FileDownload(string FullFileName)
{
FileInfo DownloadFile = new FileInfo(FullFileName);
Response.Clear();
Response.ClearHeaders();
Response.Buffer=false;
Response.ContentType="application/octet-stream";
Response.AppendHeader("Content-Disposition","attachment;filename=" +HttpUtility.UrlEncode(DownloadFile.FullName,System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length",DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
Response.Flush();
Response.End();
}
文件下载方法
最新推荐文章于 2024-12-02 07:14:15 发布
本文介绍了一种使用ASP.NET实现文件下载的方法。通过设置HTTP响应头来触发浏览器的下载行为,包括Content-Type、Content-Disposition及Content-Length等关键字段。
3872

被折叠的 条评论
为什么被折叠?



