Working with LZip Archives
Contents
[
Hide
Show
]Overview
Lzip archives are common in Linux and use LZMA compression algorithm. Aspose.ZIP for .NET API enables you to create and manage Lzip archives in your applications without the need for third-party software. The API provides LzipArchive class to work with such archives. This class offers basic methods to perform operations on archives.
Compress A File
The following code example demonstrates how to compress a file using LzipArchive class:
1 using (LzipArchive archive = new LzipArchive())
2 {
3 archive.SetSource("data.bin");
4 archive.Save("data.bin.lz");
5 }Extract Lzip Archive
The following simple code example demonstrates how to open a Lzip archive and extract its contents:
1 using (FileStream sourceLzipFile = File.Open("data.bin.lz", FileMode.Open))
2 {
3 using (FileStream extractedFile = File.Open("data.bin", FileMode.Create))
4 {
5 using (LzipArchive archive = new LzipArchive(sourceLzipFile))
6 {
7 archive.Extract(extractedFile);
8 }
9 }
10 }