DotNetZip is a library for handling zip files in .NET applications. To use DotNetZip, you can follow these general steps:
Download the DotNetZip library from the official website or install it using a package manager like NuGet.
Reference the DotNetZip assembly in your project.
NuGet Package Manager:
Install-Package DotNetZip
Import the Ionic.Zip namespace in your code.
To create a new zip file, you can use the ZipFile class.
using (ZipFile zip = new ZipFile())
{
zip.AddFile("file1.txt", "");
zip.AddFile("file2.txt", "");
zip.Save("archive.zip");
}
To extract files from a zip file, use the ZipFile.ExtractAll method.
using (ZipFile zip = ZipFile.Read("archive.zip"))
{
zip.ExtractAll("extracted-folder");
}
You can add files to an existing zip file using the ZipFile.AddFile or ZipFile.AddEntry methods.
using (ZipFile zip = ZipFile.Read("existing-archive.zip"))
{
zip.AddFile("new-file.txt", "");
zip.Save();
}
To create or extract files from a password-protected zip, set the Password property.
using (ZipFile zip = new ZipFile())
{
zip.Password = "secure-password";
zip.AddFile("file1.txt", "");
zip.Save("encrypted-archive.zip");
}
// Extracting
using (ZipFile zip = ZipFile.Read("encrypted-archive.zip"))
{
zip.Password = "secure-password";
zip.ExtractAll("extracted-folder");
}
Work with our skilled .Net developers to accelerate your project and boost its performance.
3rd Floor, Aval Complex, University Road, above Balaji Super Market, Panchayat Nagar Chowk, Indira Circle, Rajkot, Gujarat 360005.
Abbotsford, BC
15th B Street 103, al Otaiba Dubai DU 00000, United Arab Emirates
Copyright © 2026 Niotechone Software Solution Pvt. Ltd. All Rights Reserved.