[
  {
    "Id": "544312",
    "ThreadId": "240569",
    "Html": "\r\n<p>&nbsp;I have the following when creating and merging zip files</p>\r\n<p>What the problem is : Don't know how to preserve the orginal created, modified and accessed time.</p>\r\n<p>Please advise.</p>\r\n<p>Thanks</p>\r\n<p>jhw<span style=\"font-size:x-small\"><span style=\"font-size:x-small\"><span style=\"font-size:x-small\"><span style=\"font-size:x-small\">&nbsp;</span></span></span></span></p>\r\n<p><span style=\"font-size:x-small\"><span style=\"font-size:x-small\"><span style=\"font-size:x-small\">&nbsp;</span></span></span><span style=\"color:#2b91af; font-size:x-small\"><span style=\"color:#2b91af; font-size:x-small\">ZipFile</span></span><span style=\"font-size:x-small\">\r\n zipnew = </span><span style=\"color:#2b91af; font-size:x-small\"><span style=\"color:#2b91af; font-size:x-small\">ZipFile</span></span><span style=\"font-size:x-small\">.Read(strPath);</span><span style=\"font-size:x-small\"><span style=\"font-size:x-small\">\r\n</span></span></p>\r\n<p><span style=\"font-size:x-small\"><span style=\"color:#2b91af; font-size:x-small\"><span style=\"color:#2b91af; font-size:x-small\">ZipFile</span></span><span style=\"font-size:x-small\"> zipold =\r\n</span><span style=\"color:#0000ff; font-size:x-small\"><span style=\"color:#0000ff; font-size:x-small\">new</span></span><span style=\"font-size:x-small\">\r\n</span><span style=\"color:#2b91af; font-size:x-small\"><span style=\"color:#2b91af; font-size:x-small\">ZipFile</span></span><span style=\"font-size:x-small\">(path);</span></span><span style=\"font-size:x-small\"><span style=\"font-size:x-small\">\r\n</span></span></p>\r\n<p><span style=\"font-size:x-small\"></span><span style=\"font-size:x-small\"><span style=\"font-size:x-small\">{<span style=\"color:#0000ff; font-size:x-small\"><span style=\"color:#0000ff; font-size:x-small\">using</span></span><span style=\"font-size:x-small\"> (System.IO.</span><span style=\"color:#2b91af; font-size:x-small\"><span style=\"color:#2b91af; font-size:x-small\">MemoryStream</span></span><span style=\"font-size:x-small\">\r\n mem = </span><span style=\"color:#0000ff; font-size:x-small\"><span style=\"color:#0000ff; font-size:x-small\">new</span></span><span style=\"font-size:x-small\"> System.IO.</span><span style=\"color:#2b91af; font-size:x-small\"><span style=\"color:#2b91af; font-size:x-small\">MemoryStream</span></span><span style=\"font-size:x-small\">(</span><span style=\"color:#2b91af; font-size:x-small\"><span style=\"color:#2b91af; font-size:x-small\">Convert</span></span><span style=\"font-size:x-small\">.ToInt32(zenew.UncompressedSize)))</span></span></span></p>\r\n<p>zenew.Extract(mem);</p>\r\n<p><span style=\"color:#0000ff; font-size:x-small\"><span style=\"color:#0000ff; font-size:x-small\">string</span></span><span style=\"font-size:x-small\">fn = zenew.FileName.ToString();</span></p>\r\n<p>zipold.UpdateEntry(fn, mem.ToArray());</p>\r\n<p><span style=\"font-size:x-small\">&nbsp;}</span><span style=\"font-size:x-small\">&nbsp;</span></p>\r\n<p>zipold.Save();</p>\r\n",
    "PostedDate": "2011-01-05T06:41:46.99-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "544982",
    "ThreadId": "240569",
    "Html": "\r\n<p>Hi jfw,</p>\r\n<p>First thing:&nbsp; employ using clauses around your use of ZipFile.&nbsp; It will avoid problems down the road.&nbsp; For examples, check ANY of the documentation or code examples published on codeplex.com.</p>\r\n<p>Now, on to your question:</p>\r\n<p>The modified, created, and accessed&nbsp;times are available as properties on the\r\n<a href=\"http://cheeso.members.winisp.net/DotNetZipHelp/html/6c55db80-ec01-c606-be38-2ea91a64df15.htm\">\r\nZipEntry object</a>. I think that is zenew in your code, but your code isn't complete so I'm not sure.&nbsp; In that case, you can reference zenew.AccessedTime, zenew.Modifiedtime, and zenew.CreatedTime.&nbsp; You can also set these properties on the entry\r\n in the &quot;old&quot; (being updated) zipfile.&nbsp;</p>\r\n<p>Something like this:</p>\r\n<div style=\"color:black; background-color:white\">\r\n<pre>...\r\nzenew.Extract(mem);\r\n<span style=\"color:blue\">var</span> e = zipold.UpdateEntry(zenew.FileName, mem.ToArray());\r\ne.AccessedTime = zenew.AccessedTime;\r\ne.ModifiedTime = zenew.ModifiedTime;\r\ne.CreatedTime = zenew.CreatedTime;\r\n...\r\n</pre>\r\n</div>\r\n<p>There are probably ways to do what you are doing that are more memory efficient, or faster, using streams. But what you are doing should work.</p>\r\n",
    "PostedDate": "2011-01-06T11:03:26.877-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "545106",
    "ThreadId": "240569",
    "Html": "\r\n<div>\r\n<p><span style=\"font-size:11.0pt; font-family:\">Thanks for your reply.</span></p>\r\n<p><span style=\"font-size:11.0pt; font-family:\">How would I properly code the using in this scenario?</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span><span style=\"color:#2B91AF\">ZipFile</span> zipnew =\r\n<span style=\"color:#2B91AF\">ZipFile</span>.Read(strPath);</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span><span style=\"color:#2B91AF\">ZipFile</span> zipold =\r\n<span style=\"color:blue\">new</span> <span style=\"color:#2B91AF\">ZipFile</span>(path);</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"></span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span><span style=\"color:blue\">foreach</span> (<span style=\"color:#2B91AF\">ZipEntry</span> zenew\r\n<span style=\"color:blue\">in</span> zipnew)</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span>{<span style=\"\">\r\n</span><span style=\"color:blue\">using</span> (System.IO.<span style=\"color:#2B91AF\">MemoryStream</span> mem =\r\n<span style=\"color:blue\">new</span> System.IO.<span style=\"color:#2B91AF\">MemoryStream</span>(<span style=\"color:#2B91AF\">Convert</span>.ToInt32(zenew.UncompressedSize)))</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span>{\r\n</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span><span style=\"color:blue\">string</span> fn = zenew.FileName.ToString();</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\">// at this point fn is the full path and filename</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span><span style=\"color:#2B91AF\">DateTime</span> mt = zenew.ModifiedTime;</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span><span style=\"color:#2B91AF\">DateTime</span> ct = zenew.CreationTime;</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span><span style=\"\"></span><span style=\"color:#2B91AF\">DateTime</span> at = zenew.AccessedTime;</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span><span style=\"color:#2B91AF\">DateTime</span> lm = zenew.LastModified;</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span>zenew.Extract(mem);</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span><span style=\"color:blue\">var</span> zn = zipold.UpdateEntry(fn, mem.ToArray());</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span>zn.AccessedTime = at;</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span>zn.ModifiedTime = mt;</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span>zn.CreationTime = ct;</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span>}</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span>}</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span>zipold.Save();</span></p>\r\n<p style=\"text-autospace:none\"><span style=\"font-size:10.0pt; font-family:\"><span style=\"\"></span>zipnew.Dispose();</span></p>\r\n<p><span style=\"font-size:11.0pt; font-family:\"></span></p>\r\n<p><span style=\"font-size:11.0pt; font-family:\">The <span>zipold</span> filename is truncated to just the filename and not the full path.</span></p>\r\n<p><span style=\"font-size:11.0pt; font-family:\">Thanks for your help.</span></p>\r\n<p><span style=\"font-size:11.0pt; font-family:\">Joe</span></p>\r\n<p><span style=\"font-size:11.0pt; font-family:\"></span></p>\r\n<div>\r\n<div style=\"border:none; border-top:solid #B5C4DF 1.0pt; padding:3.0pt 0in 0in 0in\">\r\n<p><b><span style=\"font-size:10.0pt; font-family:\">From:</span></b><span style=\"font-size:10.0pt; font-family:\"> Cheeso [email removed]\r\n<br>\r\n<b>Sent:</b> Thursday, January 06, 2011 1:04 PM<br>\r\n<b>To:</b> joe@eis-network.com<br>\r\n<b>Subject:</b> Re: preserve original datetime for creation date, modified date, accessed date [DotNetZip:240569]</span></p>\r\n</div>\r\n</div>\r\n<p></p>\r\n<p><span style=\"font-size:9.0pt; font-family:\">From: Cheeso</span></p>\r\n<div id=\"x_x_ThreadNotificationPostBody\" style=\"margin-bottom:24.0pt\">\r\n<p><span style=\"font-size:9.0pt; font-family:\">Hi jfw,</span></p>\r\n<p><span style=\"font-size:9.0pt; font-family:\">First thing: employ using clauses around your use of ZipFile. It will avoid problems down the road. For examples, check ANY of the documentation or code examples published on codeplex.com.</span></p>\r\n<p><span style=\"font-size:9.0pt; font-family:\">Now, on to your question:</span></p>\r\n<p><span style=\"font-size:9.0pt; font-family:\">The modified, created, and accessed times are available as properties on the\r\n<a href=\"http://cheeso.members.winisp.net/DotNetZipHelp/html/6c55db80-ec01-c606-be38-2ea91a64df15.htm\">\r\nZipEntry object</a>. I think that is zenew in your code, but your code isn't complete so I'm not sure. In that case, you can reference zenew.AccessedTime, zenew.Modifiedtime, and zenew.CreatedTime. You can also set these properties on the entry in the &quot;old&quot;\r\n (being updated) zipfile. </span></p>\r\n<p><span style=\"font-size:9.0pt; font-family:\">Something like this:</span></p>\r\n<div>\r\n<pre style=\"background:white\"><span style=\"font-size:11.5pt; color:black\">...</span></pre>\r\n<pre style=\"background:white\"><span style=\"font-size:11.5pt; color:black\">zenew.Extract(mem);</span></pre>\r\n<pre style=\"background:white\"><span style=\"font-size:11.5pt; color:blue\">var</span><span style=\"font-size:11.5pt; color:black\"> e = zipold.UpdateEntry(zenew.FileName, mem.ToArray());</span></pre>\r\n<pre style=\"background:white\"><span style=\"font-size:11.5pt; color:black\">e.AccessedTime = zenew.AccessedTime;</span></pre>\r\n<pre style=\"background:white\"><span style=\"font-size:11.5pt; color:black\">e.ModifiedTime = zenew.ModifiedTime;</span></pre>\r\n<pre style=\"background:white\"><span style=\"font-size:11.5pt; color:black\">e.CreatedTime = zenew.CreatedTime;</span></pre>\r\n<pre style=\"background:white\"><span style=\"font-size:11.5pt; color:black\">...</span></pre>\r\n</div>\r\n<p><span style=\"font-size:9.0pt; font-family:\">There are probably ways to do what you are doing that are more memory efficient, or faster, using streams. But what you are doing should work.</span></p>\r\n</div>\r\n</div>\r\n",
    "PostedDate": "2011-01-06T14:37:57.823-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "545350",
    "ThreadId": "240569",
    "Html": "\r\n<p>e.Filename = fn</p>\r\n",
    "PostedDate": "2011-01-07T05:40:34.597-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]