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();
    }
原文地址:https://www.cnblogs.com/wubiyu/p/1276604.html