Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 628
Martin Avatar asked Nov 07 '10 16:11

Martin


People also ask

Can gzip compress multiple files?

Zip can compress multiple files and even entire directory hierarchies. gzip, on the other hand, compresses only a single file. That's why we typically use it with tar, which packages multiple files/directories into a single archive file.

How do I gzip multiple files in Linux?

To compress multiple files at once using gzip , we use the gzip command with -d option followed by file names to be decompressed separated by a space. It decompresses the files main. py. gz , file.

How do I gzip multiple files in Unix?

gz or . z . If you want to compress multiple files or directory into one file, first you need to create a Tar archive and then compress the . tar file with Gzip.


2 Answers

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.

like image 160
Andrew Aylett Avatar answered Oct 03 '22 13:10

Andrew Aylett


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.

like image 45
Hans Passant Avatar answered Oct 03 '22 13:10

Hans Passant