Hi!
I would like to use Compression namespace for Array, i.e. use .NET
native Compression for compress a String, or an Array of Integer whose
elements are returned values of AscW for each char of the String.
I tried with the code available @
http://msdn2.microsoft.com/en-us/lib...am(VS.80).aspx
but with no success 'cause I obtained ms.lenght buffer.length.
This is my source code for CompressData:
Private Sub CompressData()
Dim BUFFERSIZE As Integer = DataArray.Lengt h *
Marshal.SizeOf( DataArray(0))
Dim buffer(BUFFERSI ZE - 1) As Byte
'Dump integer Array DataArray in Byte Array buffer
Dim IndexValue As Integer = 0
For Index As Integer = 0 To BUFFERSIZE - 1
If ((Index << 31) = 0) Then ' if Even
buffer(Index) = (DataArray(Inde xValue) >8)
Else
buffer(Index) = (DataArray(Inde xValue) And &HFF)
IndexValue += 1
End If
Next
Dim ms As New MemoryStream()
' Use the newly created memory stream for the compressed data.
Dim compressedzipSt ream As New GZipStream(ms,
CompressionMode .Compress, True)
compressedzipSt ream.Write(buff er, 0, buffer.Length)
' Close the stream.
compressedzipSt ream.Close()
Dim BufferOut() As Byte = ms.ToArray()
End Sub
I've got the same problem also for DecompressData with the added
difficulty of using chunk of Bytes, as reported in the previous MDSN
article.
What I'm doing wrong? Is there any work-around, any trick to use
Compression not only for stream file but also for Array of Objects? Do
you have any suggestion?
Are there any commercial libraries, with no redistribuition license,
doing this?
Thanks