asp.net 下载

 1 byte[] fileContent =null;//二进制文件
 2 Response.Clear();
 3 Response.ClearHeaders();
 4 Encoding code = Encoding.GetEncoding("gb2312");
 5 Response.ContentEncoding = code;
 6 Response.HeaderEncoding = code;//这句很重要
 7 Response.AddHeader("Content-Disposition", "attachment,inline;filename="+HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(downloadName)));//解决中文名乱码问题;
 8 //Response.ContentType = ufile.FileType;//要转换成对应的类型.
 9 if (fileContent != null)
10 {
11    Response.BinaryWrite(fileContent);//输出文件
12 }

 

posted @ 2014-02-26 09:01  fycaijing  阅读(141)  评论(0编辑  收藏  举报