标签:
/// <summary>
/// 征信材料
/// </summary>
/// <param name="fileName"></param>
public void DownLoad(string fileName = "金融交易平台-搜房金融管理后台使用说明V1.1.pdf")
{
string browser = Request.UserAgent.ToUpper();
FileStream filestream = new FileStream(Server.MapPath("/Manager/Attach/" + fileName), FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
long filesize = filestream.Length;
//让客户端浏览器正确识别这个文件的类型和文件大小
System.IO.Path.GetFileName(Server.MapPath("/Manager/Attach/" + fileName)).ToLower();
Response.ContentType = "application/octet-stream";
if (browser.Contains("FIREFOX") == true)
{
fileName = fileName;
}
else
{
fileName = HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8);
}
Response.AddHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\";");
Response.AddHeader("Content-Length", filesize.ToString());
//将文件中的数据发送到客户端
byte[] filebuffer = new byte[filesize];
filestream.Read(filebuffer, 0, (int)filesize);
Response.BinaryWrite(filebuffer);
filestream.Close();
Response.End();
}
标签:
原文地址:http://www.cnblogs.com/eric-gms/p/4595711.html