【发布时间】:2015-04-15 01:48:10
【问题描述】:
我正在处理一个在 C#/Asp.Net 中执行下载的项目,文件名中可能包含中文字符。下载单个文件时,中文文件名显示正常。但是,当下载一个ZipFile中的多个文件时,该文件夹内的文件的中文字符会显示为????或____。如何使ZipFile 保持文件名的非ASCII 字符完整?
这里是多文件下载代码:
using (ZipFile zip = new ZipFile())
{
// fileList is of type List<string>
zip.AddFiles(fileList, "files");
Response.Clear();
Response.ClearHeaders();
Response.ContentType = "application/zip";
Response.AppendHeader("content-disposition", "filename=file.zip");
zip.Save(Response.OutputStream);
Response.End();
}
以及下载单个文件的代码:
if (File.Exists(Path))
{
FileInfo fileInfo = new FileInfo(Path);
Response.Clear();
Response.ClearHeaders();
Response.ContentType = "application/x-download";
Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
Response.TransmitFile(fileInfo.FullName);
Response.End();
File.Delete(Path);
}
【问题讨论】:
标签: c# asp.net encoding dotnetzip