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