Create normal zip file programmatically

后端 未结 11 870
野的像风
野的像风 2020-12-05 00:06

I have seen many tutorials on how to compress a single file in c#. But I need to be able to create a normal *.zip file out of more than just one file. Is there anything in .

11条回答
  •  再見小時候
    2020-12-05 00:33

    Just an update on this for anyone else who stumbles across this question.

    Starting in .NET 4.5 you are able to compress a directory using System.IO.Compression into a zip file. You have to add System.IO.Compression.FileSystem as a reference as it is not referenced by default. Then you can write:

    System.IO.Compression.ZipFile.CreateFromDirectory(dirPath, zipFile);
    

    The only potential problem is that this assembly is not available for Windows Store Apps.

提交回复
热议问题