How to compress or Zip whole folder using GZipStream

BreakHead picture BreakHead · Nov 22, 2010 · Viewed 7.7k times · Source

Any idea how I can do this? I am able to compress a single file.

Answer

cdhowie picture cdhowie · Nov 22, 2010

You cannot GZip an entire folder directly, since GZip operates on a single stream of data. You will first have to turn the folder into such a stream.

One way to do this would be to create a Tar archive from the directory. This will give you a single stream to work on, and since the Tar format is not compressed, GZip will usually achieve good compression ratios on Tar files.