+1 vote
by (130 points)

Below is a simple C# code segment which fails for a LINUX created .GZ file:

ZipArchive arch;
arch = new ZipArchive(filePath + tZname, ArchiveOpenMode.Open);

Using Rebex ZIP 2015 R4.1 for .NET 4.0-4.6 (File Version 2.0.5715.0)

Thanks.

Applies to: Rebex ZIP

1 Answer

0 votes
by (58.9k points)
edited by

Rebex ZIP has high-level API for compressing/decompressing GZip archives since release 2012R2.

However, there is a separate class Rebex.IO.Compression.Gzip to work with .GZ archives.

A sample code for zipping and unzipping *.gz files follows:

    void CreateGzipArchive()
    {           
        Gzip gz = new Gzip();
        gz.Compress(@"C:\data\*.txt", TraversalMode.MatchFilesShallow, @"C:\data\archive.gz");

    }
    static void DecompressGzipArchive()
    {
        Gzip gz = new Gzip();
        gz.Decompress(@"C:\data\archive.gz", @"C:\data\unzippedFiles");
    }

You are right that the standard ZipArchive class does not support .GZ - we might improve the exception message in the case when someone tried decompressing .GZ with ZipArchive so that they learn about GZip class.

by (144k points)
The exception message has been improved in Rebex ZIP 2018 R1: https://www.rebex.net/zip.net/history.aspx#2018R1
...