首页 > 其他 > 详细

文件下载

时间:2014-08-01 13:10:31      阅读:323      评论:0      收藏:0      [点我收藏+]
public static void DownloadFile(string strFilePath)
        {
            FileInfo download = new FileInfo(strFilePath);
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.ClearHeaders();
            HttpContext.Current.Response.Buffer = false;
            HttpContext.Current.Response.ContentType = "application/octet-stream";
            HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(download.FullName, System.Text.Encoding.UTF8));
            HttpContext.Current.Response.AppendHeader("Content-Length", download.Length.ToString());
            HttpContext.Current.Response.WriteFile(download.FullName);
            HttpContext.Current.Response.Flush();
            HttpContext.Current.Response.End();
        }

 

文件下载,布布扣,bubuko.com

文件下载

原文:http://www.cnblogs.com/ysf123/p/3884492.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!