Working with 7z Archives

Overview

7-Zip is a file archiver with a high compression ratio. Aspose.ZIP API lets work with creating and managing 7-Zip archives in your applications without the need of any other 3rd party applications. Aspose.ZIP API provides  SevenZipArchive class to work with 7-Zip archives. This class provides various methods to perform operations on archives. API provides the  SevenZipArchiveEntry class to represents a single file within the 7z archive.

Create a 7-Zip Single Entry

The following code example demonstrates how to create a 7-Zip entry using SevenZipArchive instance.

Create 7-Zip Archive Entries

The SevenZipArchive class provides CreateEntries methods to add files and directories recursively in the given directory given. The following code example demonstrates how to create 7-Zip archive entries.

7-Zip Encryption Settings

Aspose.ZIP API provides SevenZipAESEncryptionSettings class which provides Settings for AES encryption or decryption for 7z archives. The following code example demonstrates how to provide AES Encryption Settings.

The AES-256 is the only possible encryption method for the 7z archive.

7-Zip Archive with LZMA Compression

The following code example demonstrates how to create a 7z archive with LZMA compression and AES encryption.

Similarly you can compose 7z archive with BZip2, PPMd and LZMA2 compression method, or store files without compression.

Setting Different Password for Entries

The following code example demonstrates how to create an archive with entries encrypted with different passwords for each entry.

Extraction of 7z archives

Now Aspose.ZIP can extract LZMA, LZMA2, BZip2 and PPMd compressed archives.

The following code example demonstrates how to extract 7z archive to directory.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.