Tom-Net

导航

asp.net 文件下载

   protected void down(string filePath)
    {
        Response.Buffer 
= true;
        Response.Clear();
        Response.ContentType 
= "application/octet-stream";
        Response.AddHeader(
"Content-Disposition""attachment;FileName=" + HttpUtility.UrlEncode("MedusaSetUp.rar", Response.HeaderEncoding));
        FileStream fs 
= File.Open(filePath, FileMode.Open);
        
byte[] ss = new byte[fs.Length];
        fs.Read(ss, 
0, (int)fs.Length);
        fs.Close();
        Response.BinaryWrite(ss);
        Response.Flush();
        Response.End();
    }

posted on 2009-06-27 20:47  Tom_Net  阅读(92)  评论(0)    收藏  举报