Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>longbkit</strong>, Thank you for that reference. There is code in there:</p> <pre><code> public static void CompressData(byte[] inData, out byte[] outData) { using (MemoryStream outMemoryStream = new MemoryStream()) using (ZOutputStream outZStream = new ZOutputStream(outMemoryStream, zlibConst.Z_DEFAULT_COMPRESSION)) using (Stream inMemoryStream = new MemoryStream(inData)) { CopyStream(inMemoryStream, outZStream); outZStream.finish(); outData = outMemoryStream.ToArray(); } } public static void DecompressData(byte[] inData, out byte[] outData) { using (MemoryStream outMemoryStream = new MemoryStream()) using (ZOutputStream outZStream = new ZOutputStream(outMemoryStream)) using (Stream inMemoryStream = new MemoryStream(inData)) { CopyStream(inMemoryStream, outZStream); outZStream.finish(); outData = outMemoryStream.ToArray(); } } public static void CopyStream(System.IO.Stream input, System.IO.Stream output) { byte[] buffer = new byte[2000]; int len; while ((len = input.Read(buffer, 0, 2000)) &gt; 0) { output.Write(buffer, 0, len); } output.Flush(); } </code></pre> <p>It works. But what I see is the only diffrence between Compression and Decompression is Compression Type in ZOutput Constructor...</p> <p>Amazing. For me would be more clear if Compression is called Output while Decompression - Input. or such.. in fact it's Output only.</p> <p>❋ user "John Smith" broke original code since CopyTo doesn't work and raises exception in his edited text (And approved twice by others...). Reverting back to original code example by OP. Please test edited code next time before editing, thank you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload