How to compress multiple files in a GZip file with the GZipStream class?
Asked Answered
A

3

8

I am simply looking for a way to compress multiple files in a GZip file with the GZipStream class. Anybody has an idea how to do that?

Aretina answered 7/11, 2010 at 16:41 Comment(0)
D
8

In general, the gzip format doesn't support multiple files. Traditionally, one bundles multiple files using tar before compressing the result; you probably want to do something similar.

Dutch answered 7/11, 2010 at 16:45 Comment(0)
V
3

The gzip file format is an archive format, it contains a header and a directory that lists all of the compressed files in the archive. GZipStream merely compresses data written to the stream. The equivalent of one file in the archive, it is not capable of generating the archive format.

A popular solution is SharpZipLib, there are many others.

Vergara answered 7/11, 2010 at 16:51 Comment(0)
O
0

Old topic, but can help future readers.

I've found this solution (here) which propose to compress/decompress a directory using GZipStream native class.

The example create file list using Directory.GetFiles, but it's easy to change this point and adapt it to your needs.

Note : the compressed file is not a gzip file which can be opened by thrid-party software, but it's a good solution for your app internal management (personally I use it to transfer my application patch files over the network).

Orleans answered 9/4, 2013 at 11:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.