您的位置:首页 > 编程语言 > ASP

asp.net读取服务器物理路径下载文件

2007-06-16 12:46 423 查看
     protected void get_download(string fl_path){
   try
   {
    string filepath = fl_path;
    string filename = System.IO.Path.GetFileName(filepath);
    Response.Clear();
    Response.ClearHeaders();
    Response.Buffer=false;
    Response.ContentType = "application/octet-stream";
    //Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8");
    Response.AddHeader("Content-Disposition", "attachment; filename="+System.Web.HttpUtility.UrlEncode(filename,Encoding.UTF8));
    Response.WriteFile(filepath);
    Response.Flush();
    Response.End();
   }
   catch(Exception E){
    alert("没有找到您所要下载的数据!");
   }
  }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐