如何解决http输出 中文的文件名时出现 文件名乱码的问题
如何解决http输出 中文的文件名时出现 文件名乱码的问题?用了response.Charset = "UTF-8 "; 也不行,在“文件下载”对话框中显示的文件名,如果该文件名是纯字母的或纯数字的,就会显示正确的文件名;如果该文件名是 中文汉字的,就出现乱码,如何解决这个问题啊?谢谢!
FileInfo file = new System.IO.FileInfo(request.PhysicalPath);
response.Clear();
response.AddHeader( "Content-Disposition ", "attachment; filename= " + file.Name);
response.AddHeader( "Content-Length ", file.Length.ToString());
response.Charset = "UTF-8 ";
string fileExtension = file.Extension.ToLower();
switch (fileExtension)
{
case ".mp3 ":
response.ContentType = "audio/mpeg3 ";
break;
case ".mpeg ":
response.ContentType = "video/mpeg ";
break;
case ".jpg ":
response.ContentType = "image/jpeg ";
break;
case "bmp ":
response.ContentType = "image/bmp ";
break;