473,401 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

GZipStream Decompression.

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
1 3059

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Craig Buchanan | last post by:
when i try to open a file that has been compressed with GZipStream (source from microsoft's 101 Samples for Visual Studio 2005), i get an "invalid archive" message from winzip, zipgenius and xp's...
1
by: hakan.thornqvist | last post by:
I am using GZipStream for compression, and the size and contents of the compressed byte array differs from time to time, using the same source. byte uncompressed =...
1
by: sedwick | last post by:
I'm using .NET 2.0.50727 in VS 2005 Pro, ENU Service Pack 1 (KB926601). I've been experimenting with the System.IO.Compression classes GZipStream and DeflateStream, and I found it interesting to...
0
by: pierreuk | last post by:
Hi All, I have been looking at the best way of doing this but can't find a solution that doesn't involve using bytes array. Basically I want to wrap a XmlTextWriter in a GZipStream so I produce...
6
by: =?Utf-8?B?QkRSaWNoYXJkc29u?= | last post by:
Hi, I have been using the new GZipStream classes, and have been experiencing problems when attemping to decompress files, which from experience, seem to be failing when the original file size...
4
by: Arnie | last post by:
Folks, The GZipStream class in .NET is throwing an exception during an OS unseal/power up (first boot experience). The .NET system is fully up as other apps seem to run fine.
0
by: DR | last post by:
Why is its substantialy slower to load 50GB of gzipped file (20GB gzipped file) then loading 50GB unzipped data? im using System.IO.Compression.GZipStream and its not maxing out the cpu while...
2
by: DR | last post by:
Why is its substantialy slower to load 50GB of gzipped file (20GB gzipped file) then loading 50GB unzipped data? im using System.IO.Compression.GZipStream and its not maxing out the cpu while...
2
by: =?Utf-8?B?TWFydGluIE1hZHJlemE=?= | last post by:
Hi, i've got problems with CryptoStream and GZipStream. Someone tried that? Or got any idea why this wont work? i tried every combination, first i used CryptoStream, after that GZipStream. Or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.