views:

49

answers:

2

How can I zip more than 1 file in a GZipStream? I have 3 xml files and I want to zip them into one .gz file and when I decompress I should get all 3 separate files.

How can I do this?

+1  A: 

gzip is only designed to hold a single file. You will need to collate them in some other container before gzipping them.

Ignacio Vazquez-Abrams
i did'nt get collate them in some other container... please throw some more light on this Abram
Sathish
He's saying the same thing as Matthew - you'll need to combine the three files into one file *before* you compress.
Charlie Salts
how do i do that??
Sathish
First you pick a container, like, say, JSON. Then you create a JSON string containing the three files. And then you compress the JSON string.
Ignacio Vazquez-Abrams
+1  A: 

You can tar them together first. SharpZipLib has support for tar, as well as its own GZip implementation. See the SharpZipLib.Tar namespace. The docs are here.

Matthew Flaschen
is it a microsoft library or 3rd party?? coz my client does not accept third parties...
Sathish
It's third-party class. That seems like a rather arbitrary requirement.
Matthew Flaschen
is there any other method in microsoft .net to zip files???
Sathish
You can see [this question](http://stackoverflow.com/questions/940582/how-do-i-zip-a-file-in-c-using-no-3rd-party-apis). But note that ZipPackage isn't a general-purpose Zip class.
Matthew Flaschen