Working with Z Archives
Contents
[
Hide
Show
]Overview
Compress is a Unix shell utility producing an archive with .Z extension. Aspose.ZIP for .NET API lets work with creating and managing Z archives in your applications without the need of any other 3rd party applications. Aspose.ZIP API provides ZArchive class to work with such archives. This class provides basic methods to perform operations on archives.
This utility iplements LZC algorithm which is modification of LZW algorithm.
Compress A File
The following code example shows how to compress a file using ZArchive instance.
1 using (FileStream source = File.Open("alice29.txt", FileMode.Open, FileAccess.Read))
2 {
3 using (ZArchive archive = new ZArchive())
4 {
5 archive.SetSource(source);
6 archive.Save("alice29.txt.Z");
7 }
8 }
Open Z Archive
The following code example shows how to open a Z archive.
1 FileInfo fi = new FileInfo("data.bin.Z");
2
3 using (ZArchive archive = new ZArchive(fi.OpenRead()))
4 {
5 archive.Extract("data.bin");
6 }
Save to Stream
The following code example shows how to save to stream.
1 MemoryStream ms = new MemoryStream();
2 using (FileStream source = File.Open("alice29.txt", FileMode.Open, FileAccess.Read))
3 {
4 using (ZArchive archive = new ZArchive())
5 {
6 archive.SetSource(source);
7 archive.Save(ms);
8 }
9 }