文件下载

参数说明
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() ;
}

阅读更多
文章标签: string
个人分类: Asp.Net(c#)
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭