Parallel LZMA2 in 7z Archives
Contents
[
Hide
Show
]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#
- Define compression settings using
SevenZipLZMA2CompressionSettings
and setCompressionThreads = 4
to enable multi-threaded compression. - Create an instance of
SevenZipEntrySettings
using the compression settings from step 1. - Initialize a
SevenZipArchive
object with the entry settings. - Add a new entry to the archive by calling
CreateEntry
, specifying the entry name(first.bin)
and the source file(data.bin)
. - Save the archive as
result.7z
using theSave
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 }