There are many compression format to use to archive files for many reasons. Listed below are some compression libraries for C# of popular compression format like Zip, 7z/SevenZip, Rar.

SharpZipLib
GPL with exceptionC# ZIP GZip Tar BZip2

From the site:

#ziplib (SharpZipLib, formerly NZipLib) is a Zip, GZip, Tar and BZip2 library written entirely in C# for the .NET platform. It is implemented as an assembly (installable in the GAC), and thus can easily be incorporated into other projects (in any .NET language). The creator of #ziplib put it this way: “I’ve ported the zip library over to C# because I needed gzip/zip compression and I didn’t want to use libzip.dll or something like this. I want all in pure C#.”

Feature:

  • Source code and samples
  • Support Zip, GZip, Tar, BZip2
  • .NET 1.1, .NET 2.0 (3.5, 4.0), .NET Compact Framework 1.0, .NET Compact Framework 2.0
  • Can be used for commercial / closed source application

License

The library is released under the GPL with the following exception:

Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination.

As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.

Note

The exception is changed to reflect the latest GNU Classpath exception. Older versions of #ziplib did have another exception, but the new one is clearer and it doesn’t break compatibility with the old one.

Bottom line

In plain English this means you can use this library in commercial closed-source applications.


Site icsharpcode.github.io/SharpZipLib/
Source github.com/icsharpcode/SharpZipLib

SharpCompress
Ms-PLC# Rar 7-zip Zip Tar GZip BZip2

From the site:

SharpCompress is a compression library for .NET/Mono/Silverlight/WP7 that can unrar, un7zip, unzip, untar unbzip2 and ungzip with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip is implemented.  The major feature is support for non-seekable streams so large files can be processed on the fly (i.e. download stream).

Feature:

  • Source code fully C#
  • Support format Rar, 7-zip, Zip, Tar, GZip, BZip2
  • Support for non-seekable streams, large files can be processed on the fly like download stream
  • .NET, Mono, Silverlight, WP7

License

Freeware, but for detail please check Microsoft Public License (Ms-PL)


Site sharpcompress.codeplex.com/
Source github.com/adamhathcock/sharpcompress

LZMA SDK
Public DomainC# C++ 7-zip LZMA

From the site:

The LZMA SDK provides the documentation, samples, header files, libraries, and tools you need to develop applications that use LZMA compression.

License

LZMA SDK is placed in the public domain.


Site www.7-zip.org/sdk.html
Source

Article: C# Use Zip Archives without External Libraries
CPOLC# Zip

From the site:

Since .NET 3.0, we can use the System.IO.Packaging ZipPackage class in WindowsBase.DLL. It’s just 1.1 MB, and it just seems to fit a lot better than importing Java libraries.

Problem only that the ZipPackage class isn’t a generic Zip implementation, it’s a packaging library for formats like XPS and Office Open XML that happen to use Zip.

To access simple Zip archives with ZipPackage fails because the content is checked for Package conventions.

For example, there has to be a file [Content_Types].xml in the root and only files with specified extensions are accessible. Filenames with special characters and spaces are not allowed and the access time is not the best because of the additional Package link logic.

However, the assembly WindowsBase.DLL is preinstalled and the generic Zip implementation is inside. The only problem is that the generic Zip classes are not public and visible for the programmers. But there is a simple way to get access to this hidden API and I wrote a small wrapper class for this.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Site www.codeproject.com/Articles/209731/Csharp-use-Zip-archives-without-external-libraries
Source do not forget to check the discussion

DotNetZip
Ms-PLC# Zip

From the site:

DotNetZip is a FAST, FREE class library and toolset for manipulating zip files. Use VB, C# or any .NET language to easily create, extract, or update zip files.
DotNetZip works on PCs with the full .NET Framework, and also runs on mobile devices that use the .NET Compact Framework. Create and read zip files in VB, C#, or any .NET language, or any scripting environment.

Feature:

  • Source code and examples
  • .NET application – Console, Winforms, WPF, ASP.NET, Sharepoint, Web services apps …
  • Supports zip passwords, Unicode, ZIP64, stream input and output, AES encryption, multiple compression levels, self-extracting archives, spanned archives, and more.

License

Freeware, but for detail please check Microsoft Public License (Ms-PL)


Site dotnetzip.codeplex.com/
Source

SevenZipSharp
Ms-PL LGPLC# Zip 7-zip Xz GZip BZip2 Tar Rar Cab

From the site:

Managed 7-zip library written in C# that provides data (self-)extraction and compression (all 7-zip formats are supported). It wraps 7z.dll or any compatible one and makes use of LZMA SDK.

SevenZipSharp is an open source wrapper for 7-zip released under LGPL v3.0. It exploits the native 7-zip dynamic link library through its COM interface and exports classes to work with various file archives. The project appeared as an improvement of www.codeproject.com/KB/DLL/cs_interface_7zip.aspx. It supports .NET and Windows Mobile .NET Compact.

Feature:

  • Encryption and passwords are supported.
  • Archive properties, multi-threading, streaming is supported…
  • Windows Mobile ARM platforms are supported.
  • Extraction from SFX archives, as well as some other formats with embedded archives is supported.
  • Extraction is supported from any archive format in InArchiveFormat – such as 7-zip itself, zip, rar or cab and the format is automatically guessed by the archive signature (since the 0.43 release).
  • Compress streams, files or whole directories in OutArchiveFormat – 7-zip, Xz, Zip, GZip, BZip2 and Tar.
    Please note that GZip and BZip2 compresses only one file at a tme.

License


Site sevenzipsharp.codeplex.com/
Source