473,466 Members | 1,290 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 9233
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.