string fileurl="xx.htm";

   string xurl=Server.MapPath("/userfiles/"+fileurl.ToString());
   System.IO.FileInfo file = new System.IO.FileInfo(xurl);
   if(file.Exists)
   {
    Response.Clear();
    Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
    Response.AddHeader("Content-Length", file.Length.ToString());
    Response.ContentType = "application/octet-stream";
    Response.Filter.Close();
    Response.WriteFile(file.FullName);              
    Response.End();
   }
   else
   {
    Response.Write("文件不存在");
    Response.End();
   }


文章来源:http://blog.163.com/asd119_cn/blog/static/11973332006101083359201

相关文章:

  • 2022-12-23
  • 2021-12-05
  • 2021-11-22
  • 2021-10-10
  • 2021-07-19
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
猜你喜欢
  • 2022-12-23
  • 2021-04-18
  • 2021-05-03
  • 2021-11-03
  • 2022-12-23
  • 2021-10-21
  • 2021-11-07
相关资源
相似解决方案