How to compress multiple files in a GZip file using the GZipStream class?

I'm just looking for a way to compress multiple files in a GZip file using the GZipStream class. Does anyone have an idea how to do this?

+7
gzipstream
source share
3 answers

In general, gzip format does not support multiple files. Traditionally, one package bundles several files using tar before compressing the result; you probably want to do something like this.

+7
source share

The gzip file format is an archive format, it contains a header and a directory listing all compressed files in the archive. GZipStream simply compresses the data written to the stream. This is the equivalent of a single file in an archive; it is not capable of generating an archive format.

A popular solution is SharpZipLib , there are many others.

+3
source share

Old topic, but may help future readers.

I found this solution ( here ) that offer to compress / unzip a directory using the native GZipStream class.

In the example, create a list of files using Directory.GetFiles, but it is easy to change this point and adapt it to your needs.

Note. the compressed file is not a gzip file that can be opened by thrid-party software, but it is a good solution for managing your application internally (I personally use it to transfer application patch files over the network).

0
source share

All Articles