Runnable C# examples for IronZip, a .NET archive library that creates, reads, and extracts ZIP, TAR, GZIP, and BZIP2 archives with password protection and configurable compression.
dotnet add package IronZipusing IronZip;
License.LicenseKey = "YOUR-LICENSE-KEY";
// Create a ZIP and add files to it
using (var archive = new IronZipArchive())
{
archive.Add("./assets/image1.jpg");
archive.Add("./assets/image2.jpg");
archive.SaveAs("output.zip");
}
// Extract it again
IronZipArchive.ExtractArchiveToDirectory("output.zip", "extracted");new IronZipArchive(9) sets the compression level, and new IronZipArchive("existing.zip") opens an archive already on disk so you can list Entries() or add more files. archive.Encrypt("P@ssw0rd", EncryptionMethods.Traditional) protects the archive; AES128 and AES256 are also available. IronTarArchive, IronGZipArchive, and IronBZip2Archive follow the same shape for the other formats.
Note that ExtractArchiveToDirectory is static — it is called on the type, not on an instance.
For production use, set a license key via License.LicenseKey = "YOUR-KEY".
Each folder contains a self-contained .NET project you can open and run:
examples/— focused snippets demonstrating individual featuresget-started/— license-key setupquickstart/— an end-to-end project scaffoldtutorials/— a longer create, read, and extract walkthrough
- Creating ZIP, TAR, GZIP, and BZIP2 archives
- Adding individual files and whole directories to an archive
- Opening an existing archive and appending to it
- Listing archive entries by name
- Extracting an archive to a directory
- Password protection with Traditional, AES128, and AES256 encryption
- Opening and extracting a password-protected archive
- Setting the compression level from 0 to 9
.NET Standard 2.0 — so .NET 8, 7, 6, 5, .NET Core 2.0+, and .NET Framework 4.6.1+. Windows, macOS, Linux, Docker, Azure, and AWS. See the documentation for environment-specific notes.
- Full documentation: ironsoftware.com/csharp/zip/docs
- API reference: ironsoftware.com/csharp/zip/object-reference/api
- Issues with these examples: file directly on this repository
- Product support: support@ironsoftware.com
This repository is maintained by Iron Software. IronZip is a commercial library — see licensing for terms and trial details.