How to Unlock Zip Archive Using C#
For decompression of traditionally password protected zip archives, we’ll use
API which is a feature-rich, powerful and easy to use API. It allows to compress & decompress ZIP, TAR, GZIP, BZ2 file formats on .NET platform without installing any software like WinRAR or 7ZIP. Moreover, developers can convert archive to another format. To add the reference, Open
package manager, search for
Aspose.ZIP and install. You may also use the following command from the Package Manager Console
Install-Package Aspose.ZIP .
Steps to Unlock Zip Archive in C#
Decompressing protected archive with
APIs can be done with just few lines of code.
- Create FileStream object with the output ZIP archive file path as parameter.
- Use the Filestream object and ArchiveLoadOptions with DecryptionPassword as parameters of Archive object.
- Open the archive entries one by one and read it.
Before executing the code below, please make sure that you have the following prerequisites on your system.
- Microsoft Windows or a compatible OS with .NET Framework, .NET Core
- Development environment like Microsoft Visual Studio
- Aspose.ZIP for .NET DLL referenced in your project
- Add namespace in relevant class file