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?
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.
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.
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).
精彩评论