首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

怎么解决http输出 中文的文件名时出现 文件名乱码的有关问题

2012-01-31 
如何解决http输出 中文的文件名时出现 文件名乱码的问题 如何解决http输出中文的文件名时出现文件名乱码的

如何解决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;

                                case   ".gif ":


                                        response.ContentType   =   "image/gif ";
                                        break;

                                case   ".doc ":

                                        response.ContentType   =   "application/msword ";

                                        break;
                                case   ".xls ":

                                        response.ContentType   =   "application/vnd.ms-excel ";
                                        break;
                                case   ".css ":

                                        response.ContentType   =   "text/css ";
                                        break;

                                default:

                                        response.ContentType   =   "application/octet-stream ";
                                        break;

                        }

                        response.WriteFile(file.FullName);

                        response.End();

[解决办法]
用GB2312编码
[解决办法]
还是字符集的问题,GB2312试试

再不行就一个个试,网络上有Charset 集合

再不行,看看你的WEB.CONFIG里设置的Charset
[解决办法]
"UTF-8 ";用这种格式!问题不解决你抽我!

热点排行