当前位置:编程学习 > C#/ASP.NET >>

中文的文件名,打开时是乱码,英文和数字都是好的

string filePath = Server.MapPath(path);//路径 
FileInfo fileInfo = new FileInfo(filePath); 
Response.Clear(); 
Response.ClearContent(); 
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment;filename=" + Name);
 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.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(Name));
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,