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 unzip password-protected or AES encrypted ZIP archives. 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.

Unzip Each File in Archive Separately

The following are the steps to access and unzip files and print the extraction progress:

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

Unzip Files into a Folder

The following steps are used to unzip files into a specific folder.

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.

Unzip AES Encrypted ZIP Files

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#.


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. You can explore more about Aspose.ZIP for .NET using documentation.

Related Articles