String Decompression

madride

New member
Joined
Jan 15, 2007
Messages
4
Programming Experience
1-3
Hi,

i'm working on a program where i'm receiving data which has been Base64 encoded and compressed which I need to decode and decompress before sending elsewhere. I've managed to decode with no problems but was looking for advice on how to decompress the resultant string.

I've read articles on using System.IO.Compression available through .Net Framework version 2.0 however as I'm using Visual Studio 2003 i believe this is unavailable to me?

Any advice is much appreciated i'm not necessarily asking for a solution but merely to be pointed in the right direction

Regards
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,283
Location
Norway
Programming Experience
10+
System.IO.Compression namespace is only available from .Net 2.0. Look into using the well-known compression library SharpZipLib.
 

madride

New member
Joined
Jan 15, 2007
Messages
4
Programming Experience
1-3
Thanks for that. I've read the information and used this in my code however during compression I now get the error "Compression method unkown"

I will find out more about how my data is compressed before continuing

Regards
 

madride

New member
Joined
Jan 15, 2007
Messages
4
Programming Experience
1-3
ZLIB is used for the compression of the string data i'm trying to uncompress. It now seems to be coming back with the error "Header Checksum Illegal". I'm setting a value on the variable "result" as I believe it can't be null before being included in the Inflate function.

I've attached the code below

Private Function decompress(ByVal str As String) As String
Dim uncompress As String
Dim bytinput As Byte()

bytinput = System.Convert.FromBase64String(str)

Dim bytinputlen As Int16 = bytinput.Length
Dim decompresser As New ICSharpCode.SharpZipLib.Zip.Compression.Inflater
decompresser.SetInput(bytinput, 0, bytinputlen)

Dim result() As Byte
ReDim result(300000)

Dim resultlen As Integer
resultlen = decompresser.Inflate(result)

'uncompress = System.Text.Encoding.UTF8.GetString(result)

End Function
 

madride

New member
Joined
Jan 15, 2007
Messages
4
Programming Experience
1-3
Managed to get this resolved. The above code works I was using an invalid string which caused the error

Thanks for the advice
 
Top Bottom