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

What is DotNetZip?

DotNetZip is an exceptionally fast and free open-source .NET library that empowers developers to programmatically create, read, and manipulate ZIP files directly within .NET applications. As a 100% managed code library, it offers outstanding versatility, running seamlessly on the full .NET Framework for PCs and the .NET Compact Framework for mobile devices. This robust class library and toolset allows software professionals to efficiently work with ZIP archives using VB, C#, or any .NET language, making it a fundamental component for diverse development scenarios.

The library's broad application support is a key strength, enabling its integration into virtually any .NET project type. Developers can utilize DotNetZip in Silverlight applications for dynamic zip file creation, within ASP.NET or classic ASP applications for server-side processing, and in WPF or Windows Forms programs for client-side archive management—including updating existing archives by renaming or deleting entries. It is also ideal for use in WCF services, SSIS scripts, and for advanced tasks like creating self-extracting archives or generating zip files directly from stream content. This comprehensive functionality solidifies DotNetZip as an indispensable, high-performance tool for all .NET-based file compression and archive manipulation needs.

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");
  zip.AddFile("fileformat.txt");
  // Save Zip
  zip.Save("fileformat.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.

 English