我需要下载一个带有法文文件名的文件,例如“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
我该如何解决?
答案 0 :(得分:2)
我认为必须使用HttpUtility.UrlPathEncode在服务器端解决问题