ZipArchive fails on "Invalid or Corrupt Zip" for .GZ zip

+1 vote
asked Sep 30, 2015 by VRamanand (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)


Applies to: Rebex ZIP

1 Answer

0 votes
answered Oct 1, 2015 by Tomas Knopp (58,890 points)
edited Oct 1, 2015 by Tomas Knopp

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.

commented Apr 6, 2018 by Lukas Pokorny (126,910 points)
The exception message has been improved in Rebex ZIP 2018 R1: