下载文件

   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();
            }
        }

posted @ 2013-07-15 13:34  木兔女侠  阅读(173)  评论(0编辑  收藏  举报