How to compress files

前端 未结 10 1111
渐次进展
渐次进展 2021-02-01 06:58

I want to compress a file and a directory in C#. I found some solution in Internet but they are so complex and I couldn\'t run them in my project. Can anybody suggest me a clear

10条回答
  •  情书的邮戳
    2021-02-01 07:37

    Using DotNetZip http://dotnetzip.codeplex.com/, there's an AddDirectory() method on the ZipFile class that does what you want:

    using (var zip = new Ionic.Zip.ZipFile())
    {
        zip.AddDirectory("DirectoryOnDisk", "rootInZipFile");
        zip.Save("MyFile.zip");
    }
    

    Bonne continuation...

提交回复
热议问题