What is the best/easiest way to create ZIP archive in .NET?

前端 未结 8 1837
感情败类
感情败类 2020-12-07 17:39

Which method do you think is the \"best\".

  • Use the System.IO.Packaging namespace?
  • Use interop with the Shell?
  • Third party librar
8条回答
  •  情书的邮戳
    2020-12-07 18:25

    Since you're targetting Framework 3.5, I'd go with System.IO.Packaging. It's a library designed specifically for zipping, and comes with the framework so there's not even an extra DLL needed by the product. The usage example is atrocious, though.

    Using the shell is unrecommended. First, it would only work on Windows XP and above. But even if you don't care about that, it's pitfalls are quite numerous (I've done it before, but only because I really had no choice).

    if you're not targetting 3.5, I'd use SharpZipLib. It's quite a good library, and even if you are using 3.5 you might consider it.

提交回复
热议问题