C#使用SevenZipSharp压缩的zip文件(环境windows),在android设备解压中文文件名乱码。
怀疑是windows使用的是GBK编码,而android的底层是linux使用的是utf-8编码。
SevenZipSharp类库压缩文件的时候有没有设置字符编码的方法。
压缩后windows上查看
android设备查看
源码:
using SevenZip;
string systemPath = System.Web.HttpContext.Current.Server.MapPath("~/bin/");//物理路径
if (Environment.Is64BitProcess)
{
SevenZipCompressor.SetLibraryPath(systemPath + "/x64/7z.dll");
}
else
{
SevenZipCompressor.SetLibraryPath(systemPath + "/x86/7z.dll");
}
//压缩
var zip = new SevenZipCompressor();
zip.ArchiveFormat = OutArchiveFormat.Zip;
zip.CompressionLevel = CompressionLevel.High;
//请先在c:\doc目录下新建一些中文名和英文名文件做对比
zip.CompressDirectory(@"c:\doc", @"c:\arch.zip");
下载地址:
百度网盘链接:https://pan.baidu.com/s/1RJ93ANMYVdPu-vE_BrMK0g
提取码:pj95