Fla wrote:
> 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/library/system.io.compression.gzipstream(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.Length *
> Marshal.SizeOf(DataArray(0))
> Dim buffer(BUFFERSIZE - 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(IndexValue) >> 8)
> Else
> buffer(Index) = (DataArray(IndexValue) And &HFF)
> IndexValue += 1
> End If
>
> Next
>
> Dim ms As New MemoryStream()
> ' Use the newly created memory stream for the compressed data.
> Dim compressedzipStream As New GZipStream(ms,
> CompressionMode.Compress, True)
> compressedzipStream.Write(buffer, 0, buffer.Length)
> ' Close the stream.
> compressedzipStream.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