[
  {
    "Id": "586692",
    "ThreadId": "251265",
    "Html": "\r\n<p>Hi all, I was wondering if someone could give me a small example of how to create a zip file using the ZipOutputStream class</p>\r\n<p>instead of the ZipFile class. It would be greatly appreciated! I have googled and searched this site for one but I've found nothing.</p>\r\n<p>Thanks!</p>\r\n",
    "PostedDate": "2011-03-25T13:33:47.507-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "586846",
    "ThreadId": "251265",
    "Html": "<p>Check the documentation.&nbsp; It's in the CHM, or online it is here:</p>\r\n<p><a href=\"http://cheeso.members.winisp.net/DotNetZipHelp/html/f93b1af1-124b-3a92-45ad-502bf5c8f065.htm\">http://cheeso.members.winisp.net/DotNetZipHelp/html/f93b1af1-124b-3a92-45ad-502bf5c8f065.htm</a></p>\r\n<p>a link at the bottom of that page (\"view TOC\") will open up the full table of contents.</p>",
    "PostedDate": "2011-03-26T00:34:25.367-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "588372",
    "ThreadId": "251265",
    "Html": "<p>Thanks Cheeso, that helped a lot... but I have one more question.</p>\r\n<p>&nbsp;</p>\r\n<p>I am trying to put a time stamp on each entry I write to an archive, but I cant figure out how.</p>\r\n<p>I am currently just replacing SharpZipLib with DotNetZip in some already existing code, and this</p>\r\n<p>is the only part I cant figure out.</p>\r\n<p>The old SharpZipLib was using a class called ZipOutputStream as well, but it worked a bit diff....</p>\r\n<p>the old code did something like:</p>\r\n<p>\r\n<pre>ZipEntry entry = New Zipentry(Path.GetFileName(file));\r\nentry.DateTime = DateTime.Now;\r\nzipOutStream.PutNextEntry(entry);</pre>\r\n</p>\r\n<p>&nbsp;</p>\r\n<p>But now, with DotNetZip, it seems as though I am not supposed to use</p>\r\n<p>ZipEntry along with ZipOutputString.... but how do I set a timestamp??</p>\r\n<p>Heres the new:</p>\r\n<p>\r\n<pre>//zipOutStream.Timestamp = ??????\r\n</pre>\r\n</p>\r\n<p>Any help would be greatly appreciated</p>",
    "PostedDate": "2011-03-29T11:33:41.047-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "588422",
    "ThreadId": "251265",
    "Html": "<p>would this work??</p>\r\n<p>ZipEntry entry = zipOutStream.PutNextEntry(file);&nbsp;&nbsp;</p>\r\n<p>entry.CreationTime = DateTime.Now;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p>zipOutStream = WriteFileToZipOutputStream(zipOutStream, file);</p>",
    "PostedDate": "2011-03-29T12:54:47.687-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "588949",
    "ThreadId": "251265",
    "Html": "<p>yes, that would work. From the documentation on PutNextEntry() :</p>\r\n<blockquote>\r\n<p>This method returns the <span class=\"code\">ZipEntry</span>. You can modify public properties on the <span class=\"code\">ZipEntry</span>, such as <a href=\"http://cheeso.members.winisp.net/DotNetZipHelp/html/f7bc4e03-e417-79e0-b024-9abc8dfd7033.htm\">Encryption</a>, <a href=\"http://cheeso.members.winisp.net/DotNetZipHelp/html/c21d4132-4533-9740-f3e0-2893e85fad67.htm\">Password</a>, and so on, until the first call to <span class=\"code\">ZipOutputStream.Write()</span>, or until the next call to <span class=\"code\">PutNextEntry()</span>. If you modify the <span class=\"code\">ZipEntry </span><em>after</em> having called <span class=\"code\">Write()</span>, you may get a runtime exception, or you may silently get an invalid zip archive.</p>\r\n</blockquote>\r\n<p>I cannot remember what specific situation I was referring to with \"you may silently get an invalid zip archive\".&nbsp; That seems like pretty impolite behavior by the library. I'll have to look into that rough edge.&nbsp; Anyway, don't do that and you'll avoid that problem.</p>\r\n<p>Here's the way to think about it: the entry metadata (like entry name, timestamp, encryption type, password, and so on) gets emitted into the zipfile stream before any of the compressed data.&nbsp; So, as soon as you call&nbsp;Write() the first time, the metadata gets written, and updating the metadata after that, won't do what you think it should do.&nbsp;</p>\r\n<p>Regarding your code: not sure why you'd assign zipOutStream variable the the result of the method WriteFileToZipOutStream().&nbsp; Seems inappropriate, just from my understanding of what you are doing.</p>",
    "PostedDate": "2011-03-30T10:15:27.617-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]