本文介绍了DotNetZip麻烦编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用DotNetZip。当我归档文件,其中有英文名称的所有正常。但是当我归档文件的结果存档俄文名字与文件的坏名。一些peoplese说字符串
I am using DotNetZip. When i am archiving file which have english name all normally. but when i archiving file with russian names in result archive with bad names of file. Some peoplese said that string
ZipConstants.DefaultCodePage = 866;
但它不能编译。我也用zip.UseUni codeAsNecessary属性,并转换成我的文件名UTF8和UTF7。
But it not compile. I also use zip.UseUnicodeAsNecessary properties, and convert my file names to utf8 and utf7.
推荐答案
要在DotNetZip创建UNI code zip文件:
To create a unicode zip file in DotNetZip:
using (var zip = new ZipFile())
{
zip.UseUnicodeAsNecessary= true;
zip.AddFile(filename, "directory\\in\\archive");
zip.Save("archive.zip");
}
如果你想要一个特定的,具体的code页面,则必须使用别的东西:
If you want a particular, specific code page, then you must use something else:
using (var zip = new ZipFile())
{
zip.ProvisionalAlternateEncoding = System.Text.Encoding.GetEncoding(866);
zip.AddFile(filename, "directory\\in\\archive");
zip.Save("archive.zip");
}
这篇关于DotNetZip麻烦编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!