{
  "WorkItem": {
    "AffectedComponent": {
      "Name": "",
      "DisplayName": ""
    },
    "ClosedComment": "",
    "ClosedDate": null,
    "CommentCount": 0,
    "Custom": null,
    "Description": "The following code works fine when it is executed one time. The problem is to execute it twice or more (without disposing/re-initializing the ZipFile object):\n \n--- snip --- snip --- snip --- snip --- snip --- snip --- snip --- snip --- snip --- snip ---\nusing (var ms = new MemoryStream())\n{\n  this.WriteProjectConfig(this.ProjectConfig, ms); //provides some data in the memory stream\n  ms.Seek(0, SeekOrigin.Begin);\n  var entry = this.ZipFile[CONFIG_FILE_NAME];\n  if (entry != null)\n  {\n    this.ZipFile.RemoveEntry(entry);\n//!!    this.ZipFile.Save(pathAndFilename); //workaround, otherwise file content in zip might be zero bytes\n  }\n  this.ZipFile.AddEntry(CONFIG_FILE_NAME, ms);\n  this.ZipFile.Save(pathAndFilename);\n}\n--- snip --- snip --- snip --- snip --- snip --- snip --- snip --- snip --- snip --- snip ---\n \nThe 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. The second++ 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. But this data somehow gets lost.\n \nI use Ionic.Zip.Reduced Version 1.9.1.8.",
    "LastUpdatedDate": "2013-02-21T18:42:53.95-08:00",
    "PlannedForRelease": "",
    "ReleaseVisibleToPublic": false,
    "Priority": {
      "Name": "Low",
      "Severity": 50,
      "Id": 1
    },
    "ProjectName": "DotNetZip",
    "ReportedDate": "2012-03-17T07:36:29.5-07:00",
    "Status": {
      "Name": "Proposed",
      "Id": 1
    },
    "ReasonClosed": {
      "Name": "Unassigned"
    },
    "Summary": "ZipEntry not saved when removing/re-adding it twice",
    "Type": {
      "Name": "Issue",
      "Id": 3
    },
    "VoteCount": 2,
    "Id": 14826
  },
  "FileAttachments": [],
  "Comments": [
    {
      "Message": "Sorry Guys. Currently I CANNOT REPRO this myself. I will try to add a repro project later. You may close this issue for now, if you want. Karlo",
      "PostedDate": "2012-03-17T23:10:18.697-07:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2012-03-19T02:36:39.85-07:00",
      "Id": -2147483648
    },
    {
      "Message": "I'm seeing this same issue with\r\n\r\n            Try\r\n                ' single file or folder\r\n                Using zip As ZipFile = New ZipFile\r\n                    zip.AddFile(Environment.ExpandEnvironmentVariables(DbName))\r\n                    zip.AddFile(Environment.ExpandEnvironmentVariables(DbLogName))\r\n                    zip.Save(Environment.ExpandEnvironmentVariables(ZipName))\r\n                End Using\r\n            Catch e As Exception\r\n                With zsStatus\r\n                    .Completed = False\r\n                    .Description = \"Error adding files to ZIP file.\"\r\n                End With\r\n                Exit Sub\r\n            End Try\r\n\r\n\r\nCode will run first time but rerunning a few times it stalls on the zip.Save.\r\nNo exception thrown or error raised.",
      "PostedDate": "2012-07-20T01:42:22.51-07:00",
      "Id": -2147483648
    },
    {
      "Message": "A few further details\r\n\r\nv1.9.1.8\r\n\r\nRunning each time closing application down between runs generates zip files of different sizes.\r\n\r\nRun 1 164kb\r\nRun 2 167kb\r\nRun 3 164 kb\r\nRun 4 Stalls\r\nRun 5 165 kb",
      "PostedDate": "2012-07-20T02:19:20.503-07:00",
      "Id": -2147483648
    },
    {
      "Message": "I have identified the cause of the problems I was having.\r\nThe Dispose method of the zip object needed to be explicitely called - dereferencing the object with zip=nothing is not sufficient.\r\nI presume this is as a result of streams still containing data which would explain the inconsistent size of the zip files and concurrent access may be the reason for the hang.",
      "PostedDate": "2012-07-20T07:56:41.567-07:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2013-02-21T18:42:53.95-08:00",
      "Id": -2147483648
    }
  ]
}