码迷,mamicode.com
首页 > 其他好文 > 详细

文件下载

时间:2014-08-01 13:10:31      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   文件   ar   

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

文件下载

标签:style   blog   http   color   os   io   文件   ar   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!