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();
        }

 

posted on 2014-08-01 11:13  想要逗逼的码农  阅读(121)  评论(0编辑  收藏  举报