滨_Notepad

学习工作点滴积累
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

.net 下实现下载

Posted on 2007-12-11 21:17  新人~  阅读(172)  评论(0编辑  收藏  举报
System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath("~/upFile/abc.rar"));
        Response.Clear();
        Response.AddHeader(
"Content-Disposition""attachment;  filename=" + HttpUtility.UrlEncode(file.Name));

        Response.AddHeader(
"Content-Length", file.Length.ToString());
        Response.ContentType 
= "application/octet-stream";
        Response.WriteFile(file.FullName);
        Response.End(); 
把fileInfo的参数改为数据库中读出来的下载路径即可