[
  {
    "Id": "803760",
    "ThreadId": "346867",
    "Html": "\r\n<p>Hello List!</p>\r\n<p>I have the following code:</p>\r\n<div style=\"color:black; background-color:white\">\r\n<pre><p><span style=\"font-family:Consolas; font-size:x-small\"><span style=\"font-family:Consolas; font-size:x-small\"><span style=\"font-family:Consolas; font-size:x-small\"></span></span></span><span style=\"font-family:Consolas; font-size:x-small\"><span style=\"font-family:Consolas; font-size:x-small\"></span></span></p><div style=\"color:black; background-color:white\"><pre><span style=\"color:blue\">using</span> (<span style=\"color:blue\">var</span> ms = <span style=\"color:blue\">new</span> MemoryStream())\r\n{\r\n  <span style=\"color:blue\">this</span>.WriteProjectConfig(<span style=\"color:blue\">this</span>.ProjectConfig, ms); //provides some data in the memory stream\r\n  ms.Seek(0, SeekOrigin.Begin);\r\n  <span style=\"color:blue\">var</span> entry = <span style=\"color:blue\">this</span>.ZipFile[CONFIG_FILE_NAME];\r\n  <span style=\"color:blue\">if</span> (entry != <span style=\"color:blue\">null</span>)\r\n  {\r\n    <span style=\"color:blue\">this</span>.ZipFile.RemoveEntry(entry);\r\n<span style=\"color:green\">//!!    this.ZipFile.Save(pathAndFilename); //workaround, otherwise file content in zip might be zero bytes</span>\r\n  }\r\n  <span style=\"color:blue\">this</span>.ZipFile.AddEntry(CONFIG_FILE_NAME, ms);\r\n  <span style=\"color:blue\">this</span>.ZipFile.Save(pathAndFilename);\r\n}\r\n<p>&nbsp;</p><p>&nbsp;</p><p>This code might become executed several times, without disposing/re-initializing the ZipFile object. The first time this runs (and the file is already in the zip, thus is being removed and re-added already on the first attempt), this works well.</p><p>&nbsp;</p><p>The second&#43;&#43; time this code in executed it runs without exeception, but the file in the zip is of 0 bytes length, though the memory stream contained something like 10000 bytes of data.</p><p>&nbsp;</p><p>But this data somehow gets lost. The workaround is to do a ZipFile.Save() after removing the entry and again after adding it.</p><p>&nbsp;</p><p>I use Ionic.Zip.Reduced Version 1.9.1.8 (the latest).</p><p>&nbsp;</p><p>If this a bug in the library?</p><p>&nbsp;</p><p>Thanks</p><p>Karlo</p></pre>\r\n</div>\r\n&nbsp;</pre>\r\n</div>\r\n",
    "PostedDate": "2012-03-01T06:16:06.42-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]