Zipping a file using DotNetZip on C# on mac

浪子不回头ぞ 提交于 2019-12-02 18:22:37

问题


I am trying to zip a file or directory in C# using the following snippet of code on a mac that uses DotNetZip. But I get some exceptions below, what am I doing wrong?

using Ionic.Zip;

namespace CSLab
{
   class Program
   {
      static void Main(string[] args)
      {
         using (ZipFile zip = new ZipFile())
         {
            zip.Password = "password";
            zip.AddDirectory("./test");
            zip.Save("a.zip");
         }
      }
   }
}


Unhandled Exception: System.ArgumentException: 'IBM437' is not a 
supported encoding name. For information on defining a custom 
encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
  at System.Globalization.EncodingTable.GetCodePageFromName(String name)
  at System.Text.Encoding.GetEncoding(String name)
  at Ionic.Zip.ZipFile..ctor()
  at CSLab.Program.Main(String[] args) in 
  bash: line 1: 17217 Abort trap: 6           
  "/usr/local/share/dotnet/dotnet" 
  "/usr../bin/Debug/netcoreapp2.0/CSLab.dll"

来源:https://stackoverflow.com/questions/48388409/zipping-a-file-using-dotnetzip-on-c-sharp-on-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!