1. Products
  2.   Compression
  3.   .NET
  4.   DotNetZip

Open Source C# & VB.NET Library for Compression Formats

Create, Read & Manipulate popular compression file formats like ZIP, ZIP64 & BZIP2 Archives via  Free .NET API

DotNetZip is an open source .NET library that allows developers to programmatically create and read ZIP files inside .NET applications. DotNetZip is a very FAST FREE class library as well as a toolset for manipulating zip files. The library can be run on PCs with the full .NET Framework, and also can be used on mobile devices that require .NET Compact Framework. The great thing about the library is that is 100% managed code library and can be used in any .NET application.

Software professionals can read and write zip files using VB, C#, or any .NET. It can be used in a Silverlight app for dynamically creating zip files or ASP.NET app or WPF program that updates existing archives – changing entries names, deleting archive entries, or adding new entries to an archive. It can also be used with SSIS script, WCF service, Windows Forms app, old-school ASP application, creating or saving zip files from stream content, and self-extracting archives creation.

Previous Next

Getting Started with DotNetZip

To build the library you need the .NET Framework SDK v3.5, or later; or, Visual Studio 2008 or later. The library is usable by .NET 2.0 and later but to build it you need .NET 3.5 or later because some of the features were introduced in the C# v3.0.  You can easily install the package using NuGet, Please go to NuGet Package Manager -> NuGet Package Manager console, and using the below command.

Install DotNetZIP from NuGet

PM> Install-Package DotNetZip -Version # 

Generate & Split ZIP Files via .NET Library

ZIP is one of the leading file formats that are used in the industry for compressing and decompressing files.  The Open Source library DotNetZip allows developers to generate a ZIP file with ease inside their own .NET applications. It also provides functionality for Splitting ZIP files. It also provides features for searching the contents of a ZIP file.

Create Zip Free - C#

using (ZipFile zip = new ZipFile())
  // Add images
  zip.AddFile("fileformat.png", "images");
  // Add files
  zip.AddFile("fileformat.pdf", "files");
  // Save Zip

Create a Self-Extracting ZIP Files

The free DotNetZip library enables software programmers to create self-extracting ZIP files inside their own applications. The self-extracting archives can either be Windows (GUI) apps or command-line applications. You need to have .NET 2.0 on your computer to perform self-extraction. DotNetZip can read self-extracting archives (SFX) generated by WinZip, and WinZip can read SFX files generated by DotNetZip.

Read Excel Data - C#

// Add Directory
zip.AddDirectory("C:\\ZipFiles", System.IO.Path.GetFileName("C:\\ZipFiles"));
zip.Comment = "File Format Developer Guide";

// Set self extractor save options
var options = new SelfExtractorSaveOptions
  Flavor = SelfExtractorFlavor.WinFormsApplication,
  DefaultExtractDirectory = "%USERPROFILE%\\ExtractHere",
  SfxExeWindowTitle = "FilFormat",
  RemoveUnpackedFilesAfterExecute = true
// Save Zip
zip.SaveSelfExtractor("archive.exe", options);                 

Zipping or Unzipping Archive from Stream

DotNetZip supports features for zipping up files and saving the zip archive to a stream. Developers can also read a zip archive from an open stream. The great thing is that reading and writing to streams show the ability that users can save to a file as well as read from a file. Moreover, save to stream shows how to write a zip archive out without creating an intermediate file.