DotNetZip.Original 2025.1.26

There is a newer version of this package available.
See the version list below for details.
dotnet add package DotNetZip.Original --version 2025.1.26
                    
NuGet\Install-Package DotNetZip.Original -Version 2025.1.26
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotNetZip.Original" Version="2025.1.26" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotNetZip.Original" Version="2025.1.26" />
                    
Directory.Packages.props
<PackageReference Include="DotNetZip.Original" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DotNetZip.Original --version 2025.1.26
                    
#r "nuget: DotNetZip.Original, 2025.1.26"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DotNetZip.Original@2025.1.26
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DotNetZip.Original&version=2025.1.26
                    
Install as a Cake Addin
#tool nuget:?package=DotNetZip.Original&version=2025.1.26
                    
Install as a Cake Tool

DotNetZip - migrated repo

DotNetZip - Zip and Unzip in .NET (C# or any .NET language)

DotNetZip is a .NET class library and toolset for manipulating zip files. Use it to easily create, extract, or update zip files, within any .NET program.

Originally created in 2008, based on the full .NET Framework and Windows, the current version is reduced in scope, and runs on .NET 9.

DotNetZip supports these scenarios:

  • a Windows Service that periodically zips up a directory for backup and archival purposes
  • a Windows Forms app that creates AES-encrypted zip archives for privacy of archived content.
  • An administrative script in PowerShell or VBScript that performs backup and archival.
  • creating zip files from stream content, saving to a stream, extracting to a stream, reading from a stream
  • creation of self-extracting archives.

If all you want is a better DeflateStream or GZipStream class to replace the one that is built-into the .NET BCL, DotNetZip has that, too. DotNetZip's DeflateStream and GZipStream are available in a standalone assembly, based on a .NET port of Zlib. These streams support compression levels and deliver much better performance than the built-in classes. There is also a ZlibStream to complete the set (RFC 1950, 1951, 1952).

Example Usage

Here's some C# code that creates a zip file.

using (ZipFile zip = new ZipFile())
{
  // add this map file into the "images" directory in the zip archive
  zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images");
  // add the report into a different directory in the archive
  zip.AddFile("c:\\Reports\\2008-Regional-Sales-Report.pdf", "files");
  zip.AddFile("ReadMe.txt");
  zip.Save("MyZipFile.zip");
}

And this shows how you can read an existing zip file, and optionally extract entries.

using (ZipFile zip = ZipFile.Read("c:\\users\\me\\Downloads\\archive.zip"))
{
  Console.WriteLine("That zipfile contains {0} entries.", zip.Entries.Count);
  foreach (var entry in zip)
  {
     // choose to extract or not
     if (e.FileName.EndsWith(".txt")) {
       e.Extract(extractDir);
     }
  }
}

Here is some VB code that unpacks a zip file (extracts all the entries):

  Dim ZipToUnpack As String = "C1P3SML.zip"
   Dim TargetDir As String = "C1P3SML"
   Console.WriteLine("Extracting file {0} to {1}", ZipToUnpack, TargetDir)
   Using zip1 As ZipFile = ZipFile.Read(ZipToUnpack)
       AddHandler zip1.ExtractProgress, AddressOf MyExtractProgress
       Dim e As ZipEntry
       ' here, we extract every entry, but we could extract
       ' based on entry name, size, date, etc.
       For Each e In zip1
           e.Extract(TargetDir, ExtractExistingFileAction.OverwriteSilently)
       Next
   End Using

A Brief List of Features

  • Class library to read, extract, and update ZIP files
  • Read or write to files or streams
  • Libraries for BZip and GZip as well
  • support for various code pages (IBM437 is the default, per the ZIP spec)
  • Can read/write zip files with entry timestamps in Windows format, or in Unix format. (I'll bet you didn't know that zip files had different formats for timestamps)
  • Supports ZIP64 for archives and files over 4.2gb
  • support for Zip Input and Output streams
  • Support for DeflateStream and GZipStream
  • Event handlers for monitoring progress of Save and Extract; handy for long-running operations
  • support for Unicode comments on zip entries and archives
  • interface allows you to programmatically specify what to do when extracting would overwrite an existing file
  • lots more...

History, and Changes from the Original DotNetZip

This version of DotNetZip is now built on .NET Core.

When I created DotNetZip, I built versions of the library for the .NET Framework, the .NET Compact Framework, and for Silverlight. Also I built in COM-Interop, so you could invoke the library via any COM-enabled environment, like VB6 or perl, and so on. None of these are in scope, currently.

This version of DotNetZip builds on .NET Core. It has no dependencies on Windows libraries.

Why was DotNetZip Created?

The System.IO.Compression namespace available in the Microsoft .NET Framework {v2.0 v3.0 v3.5} included base class libraries supporting compression within streams - both the Deflate (ietf rfc-1951) and Gzip (ietf rfc-1952) compression formats are supported, in the DeflateStream and GZipStream classes, respectively.

But the System.IO.Compression namespace provides streaming compression only - useful for compressing a single stream or block of bytes, but not directly useful for creating compressed archives, like .zip files or .gzip files. The compressed archives, in addition to containing the compressed stream (or file) data, also include header information, what might be called "metadata". For .zip files, the format is defined by PKWare Inc; For gzip, the format is described in RFC-1952. But the System.IO.Compression.DeflateStream class does not parse the metadata for such files. The classes in the System.IO.Compression namespace do not (or did not, at the time DotNetZip was created) directly support formatting zip or gzip archive headers and so on.

As a result, if you wanted to build an application with the .NET Framework, c.2008, and you wanted to manipulate .ZIP files, you needed an external library to do so.

I wrote this class library to provide the handling for Zip files that the .NET Framework base class library lacked. Using this library, you can build .NET applications that read and write zip-format files. The library relies on the System.IO.Compression.DeflateStream class, to perform compression. Around that capability, the library adds logic for formatting zip headers, doing encryption and decryption, verifying zip contents, managing zip entries in an archive, and so on.

Why Another Library?

At the time DotNetZip was created, there were various Zip class libraries available for .NET applications. For example,

  • The J# runtime. (Now defunct, I imagine) it is possible to read and write zip files within .NET via the J# runtime. But some people don't like to install the extra J# DLL, which is very large, just for the zip capability. Also , the end-of-life of J# has been announced by Microsoft.

  • SharpZipLib - a 3rd party LGPL-based (or is it GPL?) library. It works, But some people don't like the license, and some don't like the programming model.

  • Commercial Tools - There are commercial tools (from ComponentOne, XCeed, etc). But some people don't want to incur the cost.

  • The System.Packaging namespace added in .NET 3.0. When I looked at it, it was a little complicated.

DotNetZip is an alternative to all of these options. It is open source, Apache licensed. It is free of cost, though donations are always welcomed. It is small and simple, but it does what you need. It does not require J#. Unlike the System.Packaging classes, DotNetZip is designed specifically for .ZIP files and is easier to use because of that.

Frequently Asked Questions

How does this Zip Library work?

DotNetZip is packaged as a single DLL, a single assembly. It is fully managed code, written in C#, and provides support for reading and writing Zip archive files and streams. The main type is ZipFile, featuring methods like Add(), Extract() and Save(). There are string and int indexers for the entries of the ZipFile. There are properties for things like password protection, unicode and codepage support, and ZIP64 behavior. And there are progress events for Reading, Saving, and Extracting.

What do I need, in order to be able to create and read zip files from within my application using this library?

To use the zip capability in your applications, you need to be using the .NET Core 9.0 or later. It is packaged on nuget as DotNetZip.Original. You do not need to download the sourcecode of DotNetZip in order to use it. You can simply download the binary.

You can use the Zip library from any application, whether a console application, a Windows-Forms application, a server-based application like an ASP.NET page, a smart-device app, a Windows Service, a Silverlight app, or something else. You can use C#, VB.NET, COBOL.NET, IronPython, IronRuby, F#, or any other .NET language. You can also use COM environments, like ASP pages, Javascript, PHP, and others. To build your application, you can use the full version of Visual Studio, or one of the Visual Studio Express tools, or just a text editor.

(TO BE COMPLETED)

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DotNetZip.Original:

Package Downloads
Avatara-Imager

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2025.2.15 30,433 2/16/2025
2025.1.26 788 1/27/2025
2025.1.25 164 1/27/2025