[
  {
    "Id": "192853",
    "ThreadId": "57077",
    "Html": "<p>Hi,</p>\r\n<p>Say I create a zip and add a file and rename it.&nbsp; How do I update the file but at the same time use the name I originally used when I first added it? Is there a simple way to do it or do I need to delete the original entry first?</p>\r\n<p>Thanks.</p>\r\n<p>--Lenard</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-05-21T09:22:16.437-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "192878",
    "ThreadId": "57077",
    "Html": "<p>?</p>\r\n<p>I'm not understanding what you want to do.</p>\r\n<pre>using (var zip = new ZipFile())\r\n{\r\n  ZipEntry e = zip.AddFile(&quot;OriginalFileName.txt&quot;, &quot;&quot;);\r\n  e.FileName= &quot;NewFileName.txt&quot;;\r\n  zip.Save(&quot;Archive.zip&quot;);\r\n}\r\n</pre>\r\n<p>Ok, with that code you've added a file to an archive, and you renamed the file entry within the archive, before saving it. Next, you want to Update the file, but use the original file name?&nbsp; I don't know exactly what that means. In the context of DotNetZip, &quot;Update&quot; means to set new content for an entry given the same filename. So you cannot &quot;Update&quot; an entry using a name that no longer exists.</p>\r\n<p>To illustrate, if you followed the above code with something like this:</p>\r\n<pre>using (var zip = ZipFile.Read(&quot;Archive.zip&quot;))\r\n{\r\n  zip.UpdateFile(&quot;OriginalFileName.txt&quot;, &quot;&quot;);\r\n  zip.Save();\r\n}\r\n</pre>\r\n<p>You would then have a zipfile with 2 entries in it. One named &quot;NewFileName.txt&quot; and one named &quot;OriginalFileName.txt&quot;.&nbsp; That's because UpdateFile() will add or update the entry - the method should actually be called &quot;Add or Update File&quot;.&nbsp; If the entry exists in the archive, it will be updated.&nbsp; If the entry doesn't exist, then it will be&nbsp;added.&nbsp; Both entries would have the same content (assuming the contents of the actual file on disk named &quot;OriginalFileName.txt&quot; did not change between the two sections of code).</p>\r\n<p>So the point is, it is not really meaningful to &quot;Update&quot; the entry in the zip file using the original file name, if the original file name is no longer associated to the entry. Do you see?</p>\r\n<p>I'm sure I have not understood what you intend.</p>\r\n<p>Maybe there is something else. Maybe you want to rename the entry, so that, instead of the 2nd stanza of code above, you did this:</p>\r\n<pre>using (var zip = ZipFile.Read(&quot;Archive.zip&quot;))\r\n{\r\n  ZipEntry e = zip[&quot;NewFileName.txt&quot;];\r\n  e.FileName = &quot;OriginalFileName.txt&quot;;\r\n  zip.UpdateFile(&quot;OriginalFileName.txt&quot;, &quot;&quot;);\r\n  zip.Save();\r\n}\r\n</pre>\r\n<p>In this case you would have a single entry, with updated content, but using the original name.</p>\r\n<p>You can also do something like this:</p>\r\n<pre>using (var zip = ZipFile.Read(&quot;Archive.zip&quot;))\r\n{\r\n  ZipEntry e = zip[&quot;NewFileName.txt&quot;];\r\n  e.FileName = &quot;OriginalFileName.txt&quot;;\r\n  e= zip.UpdateFile(&quot;OriginalFileName.txt&quot;, &quot;&quot;);\r\n  e.FileName = &quot;AnotherNewName.txt&quot;;\r\n  zip.Save();\r\n}\r\n</pre>\r\n<p>It's starting to look convoluted. But as I said, I don't understand what you want to do.</p>",
    "PostedDate": "2009-05-21T10:34:20.363-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "192888",
    "ThreadId": "57077",
    "Html": "<p>Hi Cheeso,</p>\r\n<p>What I was trying to say was that the file inside the zip is named differently than the file in the OS file system and that I wanted to update the zipped file later using the internal name.&nbsp; That said, you've provided enough info to help me with my question.</p>\r\n<p>Thanks for the quick response!</p>\r\n<p>--Lenard</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-05-21T11:07:24.46-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]