GZipLib (playing with GZipStream)

I recently needed to un-gzip (gUnzip?) a large amount of files programatically and eventually ended up with the class/library posted below.

With the GZipStream (.NET / dot net), I had seen a lot of examples compressing and decompressing strings in memory, but I needed the straight-forward, simple method of just compressing and inflating/decompressing a file (in the simplest manner).

I made the buffer size modifiable to allow you to customize the amount of RAM needed for the process.

In all of this, I discovered the proper way to name a .gz file is the name of the contents (1 file) plus the extension .gz.

Example: manish.txt becomes manish.txt.gz.

This helps tools like WinZip decipher the contents as that .gz name is used when inflating/decompressing.

With this class, you can compress and decompress with or without the output filenames.

I originally posted the C# (csharp) code here, but it was a bit sloppy, so I zipped the project (with WinZip (ha ha)).

Download the project here.

using System.IO.Compression;

GZipLib Class Diagram Snippet


Here is a tester for the library:

posted @ Friday, October 16, 2009 1:19 PM
Print

Comments on this entry:

No comments posted yet.

Your comment:



(not displayed)

 
 
 
 

Live Comment Preview: