Create normal zip file programmatically

后端 未结 11 891
野的像风
野的像风 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:24

    Here are a few resources you might consider: Creating Zip archives in .NET (without an external library like SharpZipLib)

    Zip Your Streams with System.IO.Packaging

    My recommendation and preference would be to use system.io.packacking. This keeps your dependencies down (just the framework). Jgalloway’s post (the first reference) provides a good example of adding two files to a zip file. Yes, it is more verbose, but you can easily create a façade (to a degree his AddFileToZip does that).

    HTH

提交回复
热议问题