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 }