我遇到了 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
更新
我尝试了 Ionic.Zlib.ZlibStream 和 Ionic.Zlib.DeflateStream ,我得到了同样奇怪的结果。