[
  {
    "Id": "516453",
    "ThreadId": "233322",
    "Html": "\r\n<p>&nbsp;</p>\r\n<div style=\"color:black; background-color:white\">\r\n<pre style=\"color:black\"><span style=\"font-family:'Segoe UI','Microsoft Sans Serif',Arial,Geneva,sans-serif; white-space:normal\">I have the following piece of code:</span></pre>\r\n<pre style=\"color:black\"><span style=\"font-family:'Segoe UI','Microsoft Sans Serif',Arial,Geneva,sans-serif\"><span style=\"white-space:normal\"><br></span></span></pre>\r\n<pre style=\"color:black\"><span style=\"font-family:'Segoe UI','Microsoft Sans Serif',Arial,Geneva,sans-serif; white-space:normal\"><div style=\"color:black; background-color:white\"><pre><span style=\"color:blue\">byte</span>[] buffer = <span style=\"color:blue\">new</span> <span style=\"color:blue\">byte</span>[16384];\r\n<span style=\"color:blue\">int</span> bytesRead;\r\n<span style=\"color:blue\">uint</span> totalRead = 0;\r\nStream outStream;\r\n\r\n<span style=\"color:blue\">long</span> posStart = <span style=\"color:blue\">this</span>.ZipFileStream.Position;\r\n<span style=\"color:blue\">long</span> sourceStart = _source.Position;\r\n\r\nDeflateStream outStream = <span style=\"color:blue\">new</span> DeflateStream(_destination, CompressionMode.Compress, CompressionLevel.BestCompression);\r\n\r\n<span style=\"color:blue\">do</span>\r\n{\r\n\tbytesRead = _source.Read(buffer, 0, buffer.Length);\r\n\ttotalRead &#43;= (<span style=\"color:blue\">uint</span>)bytesRead;\r\n\t<span style=\"color:blue\">if</span> (bytesRead &gt; 0)\r\n\t{\r\n\t\toutStream.Write(buffer, 0, bytesRead);\r\n\t}\r\n} <span style=\"color:blue\">while</span> (bytesRead == buffer.Length);\r\noutStream.Flush();\r\n\r\n<span style=\"color:blue\">long</span> compressedSize = outStream.TotalOut;\r\n</pre>\r\n</div>\r\n</span></pre>\r\n<pre style=\"color:black\"><span style=\"font-family:'Segoe UI','Microsoft Sans Serif',Arial,Geneva,sans-serif; white-space:normal\"><br></span></pre>\r\n<pre style=\"color:black\"><span style=\"font-family:'Segoe UI','Microsoft Sans Serif',Arial,Geneva,sans-serif; white-space:normal\">In this piece of code I want to compress a given (_source) stream into an output (_destination) stream. Afterwards I want to see how many bytes have been written into the destination stream by using the TotalOut property. But this property often returns 0 or another number which not the total size of the compressed data...</span></pre>\r\n<pre style=\"color:black\"><span style=\"font-family:'Segoe UI','Microsoft Sans Serif',Arial,Geneva,sans-serif; white-space:normal\">What am I missing or doing wrong?</span></pre>\r\n</div>\r\n<p>&nbsp;</p>\r\n",
    "PostedDate": "2010-11-03T07:08:41.527-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]