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();

  }

  调用方法

  string path= Server.MapPath("fujian/"+文件名称);//path为服务器存放文件的路径

  FileDownload(path);

相关文章:

  • 2021-08-16
  • 2021-05-21
  • 2021-09-08
  • 2021-09-08
  • 2021-10-09
猜你喜欢
  • 2021-06-01
  • 2022-12-23
  • 2021-09-08
  • 2021-11-14
相关资源
相似解决方案