21

There is a similar question for 3.5 here:

Is there a built-in zip library in .NET 3.5?

that speculated that 4.0 would have it, but I can't find any info about it. If not, does anyone know why not? Seems like it would be fairly high on the list of things to include support for.

4
  • 1
    Looking for System.IO.Compression? Commented May 10, 2011 at 4:40
  • 3
    no: "... this class does not inherently provide functionality for adding files to or extracting files from .zip archives." Commented May 10, 2011 at 4:47
  • True, but it still enables you to roll your own. If you search around for "GZipStream multiple files" you'll see a lot of people have done just that. Commented May 10, 2011 at 4:55
  • 1
    The top result I saw for that search is a "roll your own" format that combines multiple files and then gzips them. Doesn't make much sense to me. Why re-invent .tar.gz? There are good tar libraries out there for .NET, they do gzip (using GZipStream), and they are interoperable with a format and a bunch of tools that have been around since 1996. Why invent something different? Commented May 11, 2011 at 4:18

4 Answers 4

15

Take a look at the System.IO.Packaging namespace, which contains support for ZIP files, but not all of the features of ZIP files.

Still, it might be enough for your needs.

Sign up to request clarification or add additional context in comments.

1 Comment

Attempting to use these classes, I found they were able to work with things like Nuget-packages and similar "bundles" (probably XAP-files too) but unable to parse regular ZIP-files as such. If your use-case is limited to parsing these sorts of files, the System.IO.Packaging namespace should be sufficient.
10

You may have already moved along, but ZiP API is added in .NET 4.5

http://msdn.microsoft.com/en-us/library/system.io.compression.ziparchive.aspx

go nuts.

1 Comment

OP asked for .NET 4.0
9

Not for 4.0, but a ZipArchive class is being considered for the next version. You can find details about this on the BCL Team blog.

Edit: Otherwise, assuming that it's still available, and depending on your definition of built in (at least it comes/came with Visual Studio), you might be able to use the J# classes to zip files as described in this article: Using the Zip Classes in the J# Class Libraries to Compress Files and Data with C#

Edit2: Though note the comments below, that the J# option is probably not the right option except in certain unusual circumstances.

2 Comments

Ohmygosh no, don't use the J# libraries. They are out of support now, if I am not mistaken, for about 4 years. Also based on Java 1.1.4, and NO security fixes in any of them. Use a real zip library.
@Cheeso: I wouldn't recommend it in general, I use sharpziplib myself, but I know that there can sometimes be companies that doesn't allow those kind of libraries but might be ok with using the J# libraries since they came with VS, so in certain situations using an older version of VS, it might be an option.
-2

Most easiest to deal with, is with sample code here.

You need to add a new assembly just to find he Zip archive.

Working with Zip files in .NET 4.5

1 Comment

OP question was about .NET 4.0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.