Unzip Files in ZIP Archives using C#

Unzip Files in C#

In the previous post, you have learned different ways of zipping files and folders into ZIP archives using Aspose.ZIP for .NET. In this post, I’ll show you how to extract or unzip files in ZIP archives using C#. We’ll also cover how to extract password-protected or AES encrypted ZIP archives programmatically. This article is divided into the following sections:

C# API to Unzip Files

Before we start, make sure you have downloaded and referenced Aspose.ZIP for .NET or installed its package using NuGet Package Manager in your project.

Unzip ZIP Files using C#

The process of unzipping ZIP files could be achieved in two way:

  • Unzip each file in ZIP separately
  • Unzip files into a specified folder

In the first method, you can explicitly access and unzip each file in the ZIP archive. Furthermore, you can print the progress of the extraction process. Whereas, the second method simply unzips the files into the specified folder.

Extract Each File in Archive Separately

The following are the steps to access and extract files and print the extraction progress in C#:

The following code sample shows how to extract files in a ZIP archive using C#.

Extract Files into a Folder

The following steps are used to extract files into a specific folder in C#.

The following C# code sample unzips files into a folder.

Unzip Password-Protected ZIP Files in C#

You can also unzip a password-protected ZIP archive using Aspose.ZIP for .NET. For this, you only need to specify the password using the ArchiveLoadOptions class that will be passed as a second parameter to the Archive‘s constructor.

The following is the sample code to unzip a password-protected ZIP file.

Extract AES Encrypted ZIP Files in C#

A ZIP archive can also be encrypted with AES encryption. Aspose.ZIP for .NET supports encrypting archives with AES128, AES192, and AES256 encryption methods. Unzipping an AES encrypted ZIP file is similar to unzipping password-protected ZIP files. Just specify the decryption password using ArchiveLoadOptions class and rest will be taken care of by the API.

The following code sample shows how to unzip AES encrypted ZIP files in C#.

Get a Free API License

You can use Aspose.ZIP for .NET without evaluation limitations by getting a free temporary license.


In this article, you have learned how to unzip ZIP files using C#. Furthermore, you have seen how to unzip files in password-protected ZIP archives. The code samples have also demonstrated how to extract files in an encrypted ZIP archive in C#. You can explore more about Aspose.ZIP for .NET using documentation.

Related Articles