Decompress gzip with System.IO.Compression

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
 
G

Guest

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!
***************************
 
D

dkode8

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.
 
C

Cowboy \(Gregory A. Beamer\)

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!
*************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top