开发者

DeflateStream repeats bytes when decompressing data

I have encountered a problem with DeflateStream -- some of the data is being written repeatedly, to the end.

Here is the code:

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

Usi开发者_Python百科ng 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

How could you explain this?

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

UPDATE

I tried with Ionic.Zlib.ZlibStream and Ionic.Zlib.DeflateStream and I have got the same strange result.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜