asp.net C#实现下载文件的六种方法实例
Response.ContentType =
"application/x-zip-compressed"; Response.AddHeader
("Content-Disposition",
"attachment;filename=z.zip"); string filename =
Server.MapPath("DownLoad/aaa.zip"); Response.Trans
mitFile(filename); }
//WriteFile 实 现 下 载 protected void
Button2_Click(object sender, EventArgs
e) { /* using System.IO; */
string fileName ="aaa.zip";//客户端保存的文件
名 string
filePath=Server.MapPath("DownLoad/aaa.zip");//路径
FileInfo fileInfo = new
FileInfo(filePath); Response.Clear(); Response.C
learContent(); Response.ClearHeaders(); Response.
AddHeader("Content-Disposition",
"attachment;filename=" +
fileName); Response.AddHeader("Content-Length",
fileInfo.Length.ToString()); Response.AddHeader("C