473,320 Members | 1,600 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,320 software developers and data experts.

SharpZipLib in memory?

I know this is a horse that's been beated good and dead, but I *still* can't
find a good solution to this. I suppose I should post this on SharpZipLib's
forums, but I signed up and they never sent me a confirmation email, and I
can't resign up with the same email address. Great.

I'm trying to unzip from a byte array to a byte array using SharpZipLib.
Consider the following C# code:

MemoryStream msIn = new MemoryStream(bFile, 0, iSize);
GZipInputStream isZip = new GZipInputStream(msIn);

MemoryStream msOut = new MemoryStream();
byte[] buf = new byte[2048];
int size = 0;
while(true)
{
size = isZip.Read(buf, 0, 2048); //Fails here.
if (size > 0)
msOut.Write(buf, 0, size);
else
break;
}
isZip.Close();
return(msOut.ToArray());

I've tried a dozen different ideas posted on message boards all over the
internet, and none of them have worked. The code above comes almost directly
from the documentation (changed to read from a memorystream instead of a file
stream), but it doesn't work. I'm pulling my hair out.

Has anyone actually *done* this?

~BenDilts( void );
Oct 18 '05 #1
1 9184
BeanDog <Be*****@discussions.microsoft.com> wrote:
I know this is a horse that's been beated good and dead, but I *still* can't
find a good solution to this. I suppose I should post this on SharpZipLib's
forums, but I signed up and they never sent me a confirmation email, and I
can't resign up with the same email address. Great.

I'm trying to unzip from a byte array to a byte array using SharpZipLib.
Consider the following C# code:

MemoryStream msIn = new MemoryStream(bFile, 0, iSize);
GZipInputStream isZip = new GZipInputStream(msIn);

MemoryStream msOut = new MemoryStream();
byte[] buf = new byte[2048];
int size = 0;
while(true)
{
size = isZip.Read(buf, 0, 2048); //Fails here.
if (size > 0)
msOut.Write(buf, 0, size);
else
break;
}
isZip.Close();
return(msOut.ToArray());

I've tried a dozen different ideas posted on message boards all over the
internet, and none of them have worked. The code above comes almost directly
from the documentation (changed to read from a memorystream instead of a file
stream), but it doesn't work. I'm pulling my hair out.

Has anyone actually *done* this?


That looks like it should be okay to me - except you haven't shown
where you're actually populating bFile to start with.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Christer | last post by:
Hi all, I've been trying to use the SharpZipLib as it sounds promising and a lot of people refer to it in discussions on compression. However, I am getting some bad output, when I try to unzip a...
1
by: Calvin Slater | last post by:
I am always getting the following error when debuging ASP.NET application: Access is denied: 'ICSharpCode.SharpZipLib'. At this point I have to reboot IIS to get the web site going again. It...
1
by: Flix | last post by:
The following piece of code should turn the folder IN and its subfolders into a single tar file located in the folder OUT: using ICSharpCode.SharpZipLib; using ICSharpCode.SharpZipLib.Tar; ...
1
by: Yogi_Bear_79 | last post by:
I recently some embedded GZIP files into my project. I added the sharpziplib.dllas a referance. But when I distribute the .exe it looks for the .dll. Did I do something wrong, or miss step? I...
1
by: Brian Henry | last post by:
I keep getting this error when decompressing any zip files.. ICSharpCode.SharpZipLib.ZipException: Wrong Local header signature: 0xB023867F at...
4
by: Sam | last post by:
Hi all, Does someone knows if I can use this librairy (ICSharpCode.SharpZipLib.Zip) for free ? It is used to zip files (as you can probably guess). Thank you very much. Samuel
1
by: BeanDog | last post by:
I know this is a horse that's been beated good and dead, but I *still* can't find a good solution to this. I suppose I should post this on SharpZipLib's forums, but I signed up and they never sent...
3
by: CodeTalker | last post by:
I am new to VB.NET and SharpZipLib for that matter. I need the ability to zip a single file. I have found many examples of unzipping a zip file but not one to actually zip one. If anyone has an...
2
by: Mike P | last post by:
I am using SharpZipLib to zip some files, and now I want to give the user the option of where to save the zip file. My problem is that I am not sure how to refer to the zip file in my code, when I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.