By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,264 Members | 1,769 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,264 IT Pros & Developers. It's quick & easy.

GZipStream Decompression.

P: n/a
I'm trying to work out how to decompress a GZipStream. I'm not sure how to
allocate the destination buffer, given that I cannot query the stream to
find out the total decompressed size of the item. A hack here
http://www.geekpedia.com/tutorial191...ZipStream.html
shows that you can get the last 4 bytes of the stream and convert it into an
integer "size". But this doesn't seem right to me. I could also allocate
one huge buffer, given I know my items won't be greater than 1mb in size
(for now), but this doesn't seem right either. The MSDN documentation
example shows that of course the decompress buffer is the same size as the
original compress buffer, because it uses the information from the original
file size to allocate it.

Is there a generic solution that might work using a memory stream?

Thanks
Sep 7 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"Robinson" <it*****************@nowmyinboxisfull.comwrote in message
news:ed*******************@news.demon.co.uk...
I'm trying to work out how to decompress a GZipStream. I'm not sure how
to allocate the destination buffer, given that I cannot query the stream
to find out the total decompressed size of the item. A hack here
http://www.geekpedia.com/tutorial191...ZipStream.html
shows that you can get the last 4 bytes of the stream and convert it into
an integer "size". But this doesn't seem right to me. I could also
allocate one huge buffer, given I know my items won't be greater than 1mb
in size (for now), but this doesn't seem right either. The MSDN
documentation example shows that of course the decompress buffer is the
same size as the original compress buffer, because it uses the information
from the original file size to allocate it.

Is there a generic solution that might work using a memory stream?
I solved it by writing my own header (an int32) specifying the size of the
decompressed blob.
Sep 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.