[
  {
    "Id": "262856",
    "ThreadId": "76881",
    "Html": "<p>I'm just migrating some code from 1.6 to 1.8.4.28 and I'm mystified by the BadStateException &quot;You must call ZipFile.Save before calling any Extract method&quot;.&nbsp; So it is not possible to open a zip file readonly to extract a file?</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-12-02T11:07:36.707-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "262873",
    "ThreadId": "76881",
    "Html": "<p>no, it is possible to open, read, and then extract from a zip file.</p>\r\n<p>Normally it is done like this:</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><span style=\"color:Blue\">using</span> (<span style=\"color:Blue\">var</span> zip = ZipFile.Read(<span style=\"color:#A31515\">&quot;myarchive.zip&quot;</span>)) \r\n{\r\n    zip[<span style=\"color:#A31515\">&quot;entry1.txt&quot;</span>].Extract(<span style=\"color:#A31515\">&quot;c:\\\\extractdir&quot;</span>);\r\n}\r\n\r\n</pre>\r\n</div>\r\n<p>If you are asking about the meaning of the exception, not because you have encountered it, but because you are reading the source code and want to understand what it means, be aware that the exception in question is thrown only when the zipfile has never been saved, in other words when it is being created in memory.</p>",
    "PostedDate": "2009-12-02T11:42:36.6-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "262920",
    "ThreadId": "76881",
    "Html": "<p>Thanks.&nbsp; My root problem was reading the file, calling ZipFile.UpdateFile() on contained files (believing it was a no-op in this instance), neglecting to Save, and then trying to Extract, which results in the exception.</p>\r\n<p>In conclusion, call Save before calling any Extract method <em>on a new or updated</em> ZipFile, as proven above.</p>",
    "PostedDate": "2009-12-02T13:12:31.497-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]