下载文件

   private void downLoad(string filename)
        {
            
string path = Server.MapPath("download/")+filename;            
            FileInfo fi 
= new FileInfo(path);
            
if (fi.Exists)
            {
                Response.Clear();
                Response.AddHeader(
"Content-Disposition","attachment;filename="+Server.UrlEncode(filename));
                Response.AddHeader(
"Content-Length",fi.Length.ToString());                
                Response.ContentType 
= "application/octet-stream;charset=gb2321";
                Response.WriteFile(fi.FullName);                    
                Response.Flush(); 
                Response.Close();
            }
        }

原文地址:https://www.cnblogs.com/duyanli/p/3190996.html