asp.net下载带有法国字符的文件

时间:2011-06-03 08:03:06

标签: asp.net character-encoding download

我需要下载一个带有法文文件名的文件,例如“mé.txt”..我有这段代码:

FileStream fileStream = File.Open("filePath", FileMode.Open);
byte[] bytContent = new byte[(int)fileStream.Length];
fileStream.Read(bytContent, 0, (int)fileStream.Length);
fileStream.Close();
string fileName = "mé.txt";
Response.AddHeader("Content-disposition", "attachment; filename=" + fileName);
Response.ContentType = "application/octet-stream";
Response.ContentEncoding = Encoding.GetEncoding("ISO-8859-1");
Response.BinaryWrite(bytContent);

但问题是当我有弹出窗口保存我的文件时..我得到这个名字:mé.txt

我该如何解决?

1 个答案:

答案 0 :(得分:2)

我认为必须使用HttpUtility.UrlPathEncode在服务器端解决问题