c# 导出附件

FileInfo fileInfo = new FileInfo(downLoadFile);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment;filename=" + Path.GetFileName(downLoadFile));
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.AddHeader("Content-Transfer-Encoding", "binary");
Response.ContentType = "application/octet-stream";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
Response.WriteFile(fileInfo.FullName);
Response.Flush();
Response.End();

posted @ 2013-04-25 09:23  小さいです哥  阅读(139)  评论(0编辑  收藏  举报