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 }