Skip to main content
gamedev.net
🔒 Locked

SharpZipLib in memory?

Started by BeanDog 0 replies 250+ views
Original Post
BeanDog
BeanDog
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 );

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.