Closed xibaoning closed 1 year ago
move Length inspection AFTER compression stream is disposed or closed. 7 bytes is the header, which get's written when stream starts. Flush
is not saving data, as it would need to close frame, and then it could not be appended to anymore. Trade-off.
using var ms = new MemoryStream(); using (var zip = LZ4Stream.Encode(ms)) { var buffer2 = new byte[1024 * 64]; for (int i = 0; i < buffer2.Length; i++) buffer2[i] = (byte)i; zip.Write(buffer2, 0, 1011); zip.Flush(); int contnetlength = (int)ms.Length; // the contnetlength = 7 }