[
  {
    "Id": "638106",
    "ThreadId": "264094",
    "Html": "\r\n<p>Currently, I am adding a new entry to a ZipFile both when trying to create a new entry and when updating an existing entry. When doing the latter, I am having to first remove the entry from the ZipFile, and then re-add it with a stream containing the updated\r\n data. I was just wondering if there was a way, or if there is going to be a way, where you could directly write into an existing entry. So something like:</p>\r\n<p></p>\r\n<div style=\"color:black; background-color:white\">\r\n<pre><span style=\"color:blue\">private</span> ZipFile mZipFile;\r\n\r\n<span style=\"color:blue\">public</span> <span style=\"color:blue\">void</span> WriteIntoExistingEntry(<span style=\"color:blue\">string</span> entryName, Stream stream)\r\n{\r\n    <span style=\"color:green\">// Get the entry</span>\r\n    ZipEntry entry = mZipFile[entryName];\r\n\r\n    <span style=\"color:green\">// Get a stream to write into the entry</span>\r\n    <span style=\"color:blue\">using</span> (<span style=\"color:blue\">var</span> entryStream = entry.OutputStream)\r\n    {\r\n        <span style=\"color:green\">// Copy the new data across</span>\r\n        stream.CopyTo(entryStream);\r\n    }\r\n}\r\n</pre>\r\n</div>\r\n<p></p>\r\n<p>Kind regards</p>\r\n",
    "PostedDate": "2011-07-06T06:31:56.467-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "638154",
    "ThreadId": "264094",
    "Html": "<p>Try the ZipFile.UpdateEntry method that accepts a stream argument.</p>\r\n<p>It updates the named entry in the zipfile, replacing the content for that entry with the content read from the given stream. <a href=\"http://cheeso.members.winisp.net/DotNetZipHelp/html/fefc7f88-eed1-4901-1061-1909c23f83aa.htm\">Read all about it in the documentation</a>.</p>\r\n<p>In your case the code might look like this:</p>\r\n<div style=\"color: black; background-color: white;\">\r\n<pre><span style=\"color: blue;\">public</span> <span style=\"color: blue;\">void</span> WriteIntoExistingEntry(<span style=\"color: blue;\">string</span> entryName, Stream stream)\r\n{\r\n    mZipFile.UpdateEntry(entryName, stream);\r\n}\r\n\r\n</pre>\r\n</div>\r\n<p>The content from the stream is read, then compressed and written into the zipfile when your application calls ZipFile.Save(). Therefore the stream must remain open and readable (not disposed) until after the call to ZipFile.Save().</p>",
    "PostedDate": "2011-07-06T07:37:56.35-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]