Decompress gzip with System.IO.Compression

  • Thread starter Thread starter dkode8
  • Start date Start date
D

dkode8

Hello all,

I have a file, that is gzipped. I can decompress the file, take the
bytes read and write them to another stream. the only problem is when I
write the data to another file, the size of the byte array to write is
equivalent to the COMPRESSED file size, and not the DECOMPRESSED file
size. The examples on MSDN (which are moronic) ASSUME that you know the
size of the decompressed archive. In my particular instance, I dont
know the decompressed file size.

Is there any way to read header information or such of the compressed
archive so I know how much data to write out to my decompressed file
after I read the data from my gzip archive?

If you need more information, please let me know.

thanks

Sean
 
have not experimented with the MS stuff yet, but if it is too much to work
with, consider SharpZipLib. It may not be as easy to use, but it certainly
does not require knowing uncompressed size.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
I found a solution by setting a buffer size (4096) to coincide with the
os cluster size,

then through a while loop, i fill the buffer and write it out to my
filestream, then when it loops, the buffer is filled back up with new
data and output to the filestream again, this continues until there is
no more data to be read into the buffer, at which time the while loop
exits. This worked and I have confirmed the correct file size in my
outputted file from the gzip archive.
 
I really need to play with the new classes as I feel like an ignorant fool
right now. I have worked with a variety of compressions with SharpZipLib
without issue, but I am a bit lost on MS classes. (another thing to do on my
list).

Thanks for the info on the cluster size.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside the box!
*************************************************
 
Back
Top