DotNetZip trouble with coding

后端 未结 3 1992
猫巷女王i
猫巷女王i 2021-01-19 11:08

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. S

相关标签:
3条回答
  • 2021-01-19 11:14
    zip.AlternateEncodingUsage = ZipOption.Always;
    zip.AlternateEncoding = Encoding.UTF8;
    
    0 讨论(0)
  • 2021-01-19 11:24

    try this

    zip.AddEntry("yourfile.txt", "yourtext", Encoding.GetEncoding("utf-8"));
    

    encoding type : encoding type info

    0 讨论(0)
  • 2021-01-19 11:29

    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!

    0 讨论(0)
提交回复
热议问题