DeflateStream повторяет байты при распаковке данных - PullRequest
1 голос
/ 29 августа 2011

Я столкнулся с проблемой с DeflateStream - некоторые данные записываются неоднократно, до конца.

Вот код:

Dim bytesin As Byte() = ... ' An array of compressed bytes
Dim bytesout As Byte()
Dim count As Integer

Using ms As New MemoryStream(bytesin)
    Using ds As New Compression.DeflateStream(ms, Compression.CompressionMode.Decompress)
        Using outputStream As New MemoryStream()
            Dim buffer As Byte() = New Byte(1024) {}
            While InlineAssignHelper(count, ds.Read(buffer, 0, buffer.Length)) > 0
                outputStream.Write(buffer, 0, count)
            End While
            bytesout = outputStream.ToArray
        End Using
    End Using
End Using

Dim fs As FileStream = File.OpenWrite("fws.swf")
fs.Write(bytesout, 0, bytesout.Length)
fs.Flush()
fs.Close()


Private Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T
    target = value
    Return value
End Function

Как вы могли бы это объяснить?

http://i.stack.imgur.com/d2ffF.png

UPDATE

Я пытался с Ionic.Zlib.ZlibStream и Ionic.Zlib.DeflateStream, и я получил тот же странный результат.

...