实现下载功能

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));
//上面用了URL编码,否则中文的文件名会显示乱码
 Response.AppendHeader("Content-Length",DownloadFile.Length.ToString());
 Response.WriteFile(DownloadFIle.FullName);
 Response.Flush();
 Response.End();
}
原文地址:https://www.cnblogs.com/pyt5208/p/447030.html