[
  {
    "Id": "447555",
    "ThreadId": "213891",
    "Html": "<p>Hi</p>\r\n<p>I am zipping a file using a stream then writing the stream to file. If I run the code repeatedly the output is different each time - just a few bytes here and there. If I do the same thing using files everything is&nbsp;OK. I need to produce the same results each time, and I need to use streams to plug in to existing code.</p>\r\n<p>This is a small sample I have pulled out of the project to try to isolate and fix. I've updated from 1.8 to 1.9 and tried using the new output stream class with the same results. Any ideas?</p>\r\n<p>\r\n<div style=\"color:black;background-color:white\">\r\n<pre>        <span style=\"color:blue\">static</span> <span style=\"color:blue\">void</span> CompressUsingStreams(<span style=\"color:blue\">string</span> infile, <span style=\"color:blue\">int</span> idx) {\r\n\r\n            MemoryStream outstream = <span style=\"color:blue\">new</span> MemoryStream();\r\n            <span style=\"color:blue\">string</span> outfile = Path.Combine(Path.GetDirectoryName(infile),\r\n                                          Path.GetFileNameWithoutExtension(infile) + <span style=\"color:#a31515\">&quot;.&quot;</span> + idx + <span style=\"color:#a31515\">&quot;.ddd&quot;</span>);\r\n            \r\n            <span style=\"color:blue\">byte</span>[] filebytes = File.ReadAllBytes(infile);\r\n\r\n            <span style=\"color:blue\">if</span> (File.Exists(outfile)) { File.Delete(outfile); }\r\n\r\n            <span style=\"color:blue\">using</span> (ZipOutputStream stream = <span style=\"color:blue\">new</span> ZipOutputStream(outstream)){\r\n                stream.CompressionLevel = CompressionLevel.BestCompression;\r\n                stream.PutNextEntry(infile);\r\n                stream.Write(filebytes, 0, filebytes.Length);\r\n                stream.Close();\r\n            }\r\n            File.WriteAllBytes(outfile, outstream.ToArray());\r\n\r\n        }\r\n</pre>\r\n</div>\r\n</p>\r\n<p>I've tried with a number of files. I can replicate just using a simple text file with a handful of words in.</p>\r\n<p>Thanks,</p>\r\n<p>Lee</p>",
    "PostedDate": "2010-05-26T04:32:39.373-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "447561",
    "ThreadId": "213891",
    "Html": "<p>It's probably the timestamp.&nbsp; Usiing a stream as input for an entry, the library by default uses the current time, which obviously will be different for each run.&nbsp; Using a filesystem file&nbsp;, the library uses the timestamp on the file.&nbsp;</p>\r\n<p>You can overrride the timestamp used for an entry in a zip file by setting Atime, Mtime, Ctime or calling ZipEntry.SetEntryTimes.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2010-05-26T04:47:20.97-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "447567",
    "ThreadId": "213891",
    "Html": "<p>Hi Cheeso</p>\r\n<p>That fixed it! Thanks for the extremely fast response, and thanks for a great library.</p>\r\n<p>Lee</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2010-05-26T04:51:14.413-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]