Parallel LZMA2 in 7z Archives

Overview

Aspose.ZIP API lets compose 7-Zip archives. One of its compression methods is LZMA2, which can be compressed in several threads.

LZMA2 mutlithreaded compression

This sample composes 7z archive with the single entry, that will be compressed using 4 threads.

Steps: Create 7z Archive with LZMA2 Compression and Multi-Threading in C#

  1. Define compression settings using SevenZipLZMA2CompressionSettings and set CompressionThreads = 4 to enable multi-threaded compression.
  2. Create an instance of SevenZipEntrySettings using the compression settings from step 1.
  3. Initialize a SevenZipArchive object with the entry settings.
  4. Add a new entry to the archive by calling CreateEntry, specifying the entry name (first.bin) and the source file (data.bin).
  5. Save the archive as result.7z using the Save method.
1    SevenZipEntrySettings settings = new SevenZipEntrySettings(new SevenZipLZMA2CompressionSettings(){ CompressionThreads = 4 });
2    using (var archive = new SevenZipArchive(settings))
3    {
4        archive.CreateEntry("first.bin", "data.bin");
5        archive.Save("result.7z");
6    }
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.