Server端文件下载 .NET

 string pathfile=targetfile;  //pathfile 是要下载的文件名称 
    System.IO.FileInfo file=new System.IO.FileInfo(pathfile); 
    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(); 
局限性:紧紧能下载一个文件. 

posted on 2006-12-19 11:40  玄新  阅读(152)  评论(0编辑  收藏  举报

导航