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 name开发者_JAVA技巧s of file. Some peoplese said that string
ZipConstants.DefaultCodePage = 866;
But it not compile. I also use zip.UseUnicodeAsNecessary properties, and convert my file names to utf8 and utf7.
zip.AlternateEncodingUsage = ZipOption.Always;
zip.AlternateEncoding = Encoding.UTF8;
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");
}
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");
}
Check the documentation for those properties before using them!
try this
zip.AddEntry("yourfile.txt", "yourtext", Encoding.GetEncoding("utf-8"));
encoding type : encoding type info
精彩评论