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 @ 2008-08-26 13:14  吴碧宇  阅读(221)  评论(0编辑  收藏  举报