[
  {
    "Id": "168990",
    "ThreadId": "50425",
    "Html": "The following highlighted line is generating error &quot;Cannot access closed file&quot;<br>\r\n<br>\r\npublic static void UpdatePageNode(XmlDocument objXmlDocument, string filename, ref ZipFile ZipCPDFile)<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp; <br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using (MemoryStream ms = new MemoryStream())<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objXmlDocument.Save(ms);<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objXmlDocument = null;<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GC.Collect();<br>\r\n<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ms.Seek(0, SeekOrigin.Begin);<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ZipCPDFile.UpdateFileStream(filename, &quot;&quot;, ms);<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:red\"> ZipCPDFile.Save(ZipCPDFile.Name);</span><br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>\r\n",
    "PostedDate": "2009-03-17T05:44:26.163-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "170484",
    "ThreadId": "50425",
    "Html": "I am guessing that the ZipCPDFile is a ZipFile instance that you have initialized somewhere else?<br>\r\n<br>\r\nHave you added other entries to this ZipFile instance? <br>\r\n<br>\r\nThe rule is this:  if you call ZipFile.AddFile() (or AddItem, or UpdateItem or UpdateFile) , then the file specified in the call must be available at the time you call ZipFile.Save().  <br>\r\n<br>\r\nIf I do this: <br>\r\n<pre>  using (var zip = new ZipFile())\r\n  {\r\n      zip.AddFile(&quot;Report.csv&quot;);\r\n      System.IO.File.Delete(&quot;Report.csv&quot;);\r\n      zip.Save(&quot;MyArchive.zip&quot;);\r\n  }\r\n</pre>\r\n<p>...then I will surely get a &quot;file does not exist&quot; exception. </p>\r\n<p>Have you done something like this? </p>\r\n<p>If not, then can you produce a succint program that reproduces the problem you are seeing? Or, failing that, can you post the stack trace? I'll see what I can do. </p>\r\n",
    "PostedDate": "2009-03-21T22:44:17.29-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]