参数说明
AbsPath:文件绝对路径
FileName:文件原名
public static void DownloadFile(string AbsPath,string FileName)
{
FileStream fs = new FileStream(AbsPath, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename="+FileName);
// System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;FileName");
System.Web.HttpContext.Current.Response.Charset = "GB2312";
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
System.Web.HttpContext.Current.Response.BinaryWrite(r.ReadBytes(Convert.ToInt32(fs.Length)));
System.Web.HttpContext.Current.Response.Flush() ;
}
文件下载
最新推荐文章于 2023-11-12 23:59:38 发布