# Getting Started with IronZIP
## IronZIP: Your All-in-One Archive Library for .NET
**IronZIP** is an archive compression and decompression library developed by Iron Software. In addition to the widely used ZIP format, it can also handle TAR, GZIP, and BZIP2.
### C# Archive Compression and Decompression Library
1. [Download the C# library for file compression and decompression](https://www.nuget.org/packages/IronZip/)
2. Handle ZIP, TAR, GZIP, and BZIP2 formats
3. Customize compression levels from 0 to 9
4. Extract content from compressed archives
5. Append files to existing ZIP archives and generate new ZIP files
### Compatibility
**IronZIP** has cross-platform support compatibility with:
#### .NET Version Support:
- **C#**, **VB.NET**, **F#**
- **.NET 7, 6**, 5, and Core 3.1+
- .NET Standard (2.0+)
- .NET Framework (4.6.2+)
#### Operating Systems and Environments Support:
- **Windows** (10+, Server 2016+)
- **Linux** (Ubuntu, Debian, CentOS, etc.)
- **macOS** (10+)
- **iOS** (12+)
- **Android** API 21+ (v5 "Lollipop")
- **Docker** (Windows, Linux, Azure)
- **Azure** (VPS, WebApp, Function)
- **AWS** (EC2, Lambda)
#### .NET Project Types Support:
- **Web** (Blazor & WebForms)
- **Mobile** (Xamarin & MAUI)
- **Desktop** (WPF & MAUI)
- **Console** (App & Library)
## Installation
### IronZIP Library
To install the IronZIP package, use the following command in your terminal or package manager console:
```shell
:ProductInstall
```
Alternatively, download directly from the [official IronZIP NuGet website](https://www.nuget.org/packages/IronZip).
Once installed, you can get started by adding `using IronZip;` to the top of your C# code.
## Applying License Key
Next, apply a valid license or trial key to IronZIP by assigning the license key to the LicenseKey property of the License class. Include the following code right after the import statement, before using any IronZIP methods:
```csharp
using IronZip;
// Apply your license key here
IronZip.License.LicenseKey = "YOUR_LICENSE_KEY";
```
## Code Examples
### Create an Archive Example
Create a ZIP file using the `using` statement. Inside the using block, use the `AddArchiveEntry` method to import files into the ZIP file. Finally, export the ZIP file with the `SaveAs` method.
```csharp
using IronZip;
using System.IO;
class Program
{
static void Main()
{
// Create a new ZIP file
using (var archive = new ZipArchive())
{
// Add a file to the archive
archive.AddArchiveEntry("example.txt", File.ReadAllBytes("path/to/example.txt"));
// Save the ZIP archive
archive.SaveAs("archive.zip");
}
}
}
```
### Unarchive an Archive to Folder
Extract the content from the ZIP file using the `ExtractArchiveToDirectory` method. Specify the path of the target ZIP file and the extraction directory.
```csharp
using IronZip;
class Program
{
static void Main()
{
// path to the ZIP file and extraction directory
string zipPath = "archive.zip";
string extractPath = "extracted/";
// Extract all files in the ZIP archive to the specified directory
using (var archive = new ZipArchive(zipPath))
{
archive.ExtractArchiveToDirectory(extractPath);
}
}
}
```
### Add Files to An Existing Archive
Passing the ZIP file path to the constructor will open the ZIP file. Utilize the same `AddArchiveEntry` method to add files to the opened ZIP and export it with the `SaveAs` method.
```csharp
using IronZip;
using System.IO;
class Program
{
static void Main()
{
// Open an existing ZIP file
using (var archive = new ZipArchive("archive.zip"))
{
// Add more files to the archive
archive.AddArchiveEntry("anotherfile.txt", File.ReadAllBytes("path/to/anotherfile.txt"));
// Save updates to the ZIP archive
archive.SaveAs("archive.zip");
}
}
}
```
## Licensing & Support Available
**IronZIP** is a paid library; however, free trial licenses are also available [here](trial-license).
For more information about Iron Software, please visit our website: [https://ironsoftware.com/](https://ironsoftware.com/)
For more support and inquiries, please [ask our team](#live-chat-support).
### Support from Iron Software
For general support and technical inquiries, please email us at: [support@ironsoftware.com](mailto:support@ironsoftware.com)
IronZIP is an archive compression and decompression library developed by Iron Software. In addition to the widely used ZIP format, it can also handle TAR, GZIP, and BZIP2.
Once installed, you can get started by adding using IronZip; to the top of your C# code.
Applying License Key
Next, apply a valid license or trial key to IronZIP by assigning the license key to the LicenseKey property of the License class. Include the following code right after the import statement, before using any IronZIP methods:
using IronZip;// Apply your license key hereIronZip.License.LicenseKey = "YOUR_LICENSE_KEY";
using IronZip;
// Apply your license key here
IronZip.License.LicenseKey = "YOUR_LICENSE_KEY";
ImportsIronZip' Apply your license key hereIronZip.License.LicenseKey = "YOUR_LICENSE_KEY"
Imports IronZip
' Apply your license key here
IronZip.License.LicenseKey = "YOUR_LICENSE_KEY"
Code Examples
Create an Archive Example
Create a ZIP file using the using statement. Inside the using block, use the AddArchiveEntry method to import files into the ZIP file. Finally, export the ZIP file with the SaveAs method.
using IronZip;using System.IO;class Program{ static voidMain() { // Create a new ZIP file using (var archive = new ZipArchive()) { // Add a file to the archive archive.AddArchiveEntry("example.txt", File.ReadAllBytes("path/to/example.txt")); // Save the ZIP archive archive.SaveAs("archive.zip"); } }}
using IronZip;
using System.IO;
class Program
{
static void Main()
{
// Create a new ZIP file
using (var archive = new ZipArchive())
{
// Add a file to the archive
archive.AddArchiveEntry("example.txt", File.ReadAllBytes("path/to/example.txt"));
// Save the ZIP archive
archive.SaveAs("archive.zip");
}
}
}
ImportsIronZipImportsSystem.IOFriend Class ProgramShared Sub Main() ' Create a new ZIP fileUsing archive = New ZipArchive() ' Add a file to the archive archive.AddArchiveEntry("example.txt", File.ReadAllBytes("path/to/example.txt")) ' Save the ZIP archive archive.SaveAs("archive.zip")EndUsing End SubEnd Class
Imports IronZip
Imports System.IO
Friend Class Program
Shared Sub Main()
' Create a new ZIP file
Using archive = New ZipArchive()
' Add a file to the archive
archive.AddArchiveEntry("example.txt", File.ReadAllBytes("path/to/example.txt"))
' Save the ZIP archive
archive.SaveAs("archive.zip")
End Using
End Sub
End Class
Unarchive an Archive to Folder
Extract the content from the ZIP file using the ExtractArchiveToDirectory method. Specify the path of the target ZIP file and the extraction directory.
using IronZip;class Program{ static voidMain() { // path to the ZIP file and extraction directory string zipPath = "archive.zip"; string extractPath = "extracted/"; // Extract all files in the ZIP archive to the specified directory using (var archive = new ZipArchive(zipPath)) { archive.ExtractArchiveToDirectory(extractPath); } }}
using IronZip;
class Program
{
static void Main()
{
// path to the ZIP file and extraction directory
string zipPath = "archive.zip";
string extractPath = "extracted/";
// Extract all files in the ZIP archive to the specified directory
using (var archive = new ZipArchive(zipPath))
{
archive.ExtractArchiveToDirectory(extractPath);
}
}
}
ImportsIronZipFriend Class ProgramShared Sub Main() ' path to the ZIP file and extraction directory Dim zipPath AsString = "archive.zip" Dim extractPath AsString = "extracted/" ' Extract all files in the ZIP archive to the specified directoryUsing archive = New ZipArchive(zipPath) archive.ExtractArchiveToDirectory(extractPath)EndUsing End SubEnd Class
Imports IronZip
Friend Class Program
Shared Sub Main()
' path to the ZIP file and extraction directory
Dim zipPath As String = "archive.zip"
Dim extractPath As String = "extracted/"
' Extract all files in the ZIP archive to the specified directory
Using archive = New ZipArchive(zipPath)
archive.ExtractArchiveToDirectory(extractPath)
End Using
End Sub
End Class
Add Files to An Existing Archive
Passing the ZIP file path to the constructor will open the ZIP file. Utilize the same AddArchiveEntry method to add files to the opened ZIP and export it with the SaveAs method.
using IronZip;using System.IO;class Program{ static voidMain() { // Open an existing ZIP file using (var archive = new ZipArchive("archive.zip")) { // Add more files to the archive archive.AddArchiveEntry("anotherfile.txt", File.ReadAllBytes("path/to/anotherfile.txt")); // Save updates to the ZIP archive archive.SaveAs("archive.zip"); } }}
using IronZip;
using System.IO;
class Program
{
static void Main()
{
// Open an existing ZIP file
using (var archive = new ZipArchive("archive.zip"))
{
// Add more files to the archive
archive.AddArchiveEntry("anotherfile.txt", File.ReadAllBytes("path/to/anotherfile.txt"));
// Save updates to the ZIP archive
archive.SaveAs("archive.zip");
}
}
}
ImportsIronZipImportsSystem.IOFriend Class ProgramShared Sub Main() ' Open an existing ZIP fileUsing archive = New ZipArchive("archive.zip") ' Add more files to the archive archive.AddArchiveEntry("anotherfile.txt", File.ReadAllBytes("path/to/anotherfile.txt")) ' Save updates to the ZIP archive archive.SaveAs("archive.zip")EndUsing End SubEnd Class
Imports IronZip
Imports System.IO
Friend Class Program
Shared Sub Main()
' Open an existing ZIP file
Using archive = New ZipArchive("archive.zip")
' Add more files to the archive
archive.AddArchiveEntry("anotherfile.txt", File.ReadAllBytes("path/to/anotherfile.txt"))
' Save updates to the ZIP archive
archive.SaveAs("archive.zip")
End Using
End Sub
End Class
Licensing & Support Available
IronZIP is a paid library; however, free trial licenses are also available here.
Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.