[
  {
    "Id": "230027",
    "ThreadId": "67678",
    "Html": "<p>I'm using C++/CLI with DotNetZip and can't figure out how to close a zip file once I'm done with it. &nbsp;All the examples use the using keyword, as in</p>\r\n<p>using (ZipFile zip = new ZipFile(&quot;foo.zip&quot;))</p>\r\n<p>{</p>\r\n<p>//... etc.</p>\r\n<p>}</p>\r\n<p>This keyword is not supported in C++/CLI, however, and I can't call the Dispose or Finalize methods since they're protected. &nbsp;Is there a way I can cleanly close the file?</p>",
    "PostedDate": "2009-09-01T22:44:23.87-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "230237",
    "ThreadId": "67678",
    "Html": "<p>The no-argument Dispose() method is public.</p>\r\n<p>&quot;Using&quot; in C# is a shorthand for try....finally { object.Dispose(); }&nbsp;&nbsp;&nbsp;&nbsp; For example,</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(&quot;foo.zip&quot;)) \r\n{\r\n  <span style=\"color:Green\">// etc</span>\r\n}\r\n</pre>\r\n</div>\r\n<p>is equivalent to</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><span style=\"color:Blue\">var</span> zip = ZipFile.Read(&quot;foo.zip&quot;);\r\n<span style=\"color:Blue\">try</span>\r\n{\r\n <span style=\"color:Green\">// etc</span>\r\n}\r\n<span style=\"color:Blue\">finally</span>\r\n{\r\n  zip.Dispose();\r\n}\r\n</pre>\r\n</div>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-09-02T08:17:32.363-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "230306",
    "ThreadId": "67678",
    "Html": "<p>The Dispose() method is protected/private in the installation I downloaded.&nbsp; It turns out that this is the equivalent:&nbsp;</p>\r\n<p>&nbsp;&nbsp;&nbsp; ZipFile ^ zip;<br>&nbsp;&nbsp; &nbsp;try<br>&nbsp;&nbsp; &nbsp;{<br><br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; zip = gcnew ZipFile(&quot;test.zip&quot;);<br>&nbsp;&nbsp; &nbsp; //...</p>\r\n<p><br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp; &nbsp;finally<br>&nbsp;&nbsp; &nbsp;{<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;zip-&gt;~ZipFile();<br>&nbsp;&nbsp; &nbsp;}</p>",
    "PostedDate": "2009-09-02T10:30:54.127-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "230371",
    "ThreadId": "67678",
    "Html": "<p>Hmm, right.&nbsp; That must be some sort of impedance mismatch between the languages.&nbsp; Here's a DotNetZip &quot;hello world&quot; in C++/CLI:</p>\r\n<pre>// DotNetZip-HelloWorld.cpp\r\n//\r\n\r\n#include &quot;stdafx.h&quot;\r\n\r\nusing namespace System;\r\nusing namespace Ionic::Zip;\r\n\r\nint main(array ^args)\r\n{\r\n    Console::WriteLine(L&quot;Hello World&quot;);\r\n    Console::WriteLine(L&quot;Current directory is {0}&quot;, System::IO::Directory::GetCurrentDirectory());\r\n        \r\n    ZipFile ^ zip;\r\n    try\r\n    {\r\n        zip = gcnew ZipFile();\r\n        zip-&gt;AddEntry(&quot;Readme.txt&quot;, &quot;&quot;, &quot;This is the content.&quot;);\r\n        zip-&gt;Save(&quot;test.zip&quot;);\r\n    }\r\n    finally\r\n    {\r\n        zip-&gt;~ZipFile();\r\n    }\r\n\r\n    Console::WriteLine(L&quot;Press  to quit.&quot;);\r\n    Console::ReadLine();\r\n    return 0;\r\n}\r\n<p>&nbsp;</p></pre>",
    "PostedDate": "2009-09-02T12:30:42.077-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "447735",
    "ThreadId": "67678",
    "Html": "Hi Cheeso,\r\nFirst of all, can I just say great library, I really appreciate all the effort you are putting in to develop and support it!  I'm using it in a C++/CLI project to create encrypted and potentially multi-spanned archives, which are written to CD (hence the multi-spanning).  I also have a small app that auto-launches from the first CD, collates the fragments to a directory on the recipient machine's hard-drive, requests the password and decrypts the archive, attempting to clear up the zip fragments after the extraction is complete.\r\n\r\nAs a follow up to the above discussion, I'm getting an exception when deleting the spanned zip files after extracting, with the error text as follows:\r\n&quot;The process cannot access the file 'xxxx.z01' because it is being used by another process.&quot;\r\n\r\nI'm using Ionic.Zip.Reduced.dll v1.9.1.5, on WindowsXP\r\nThe code is broadly as follows:\r\n\r\n...\r\nZipFile^ zip;\r\ntry\r\n{\r\n    zip = ZipFile::Read(sourcePath);\r\n    zip-&gt;Password = password;\r\n    zip-&gt;ExtractAll(extractPath, ExtractExistingFileAction::OverwriteSilently);\r\n}\r\ncatch(...)\r\n{\r\n}\r\nfinally\r\n{\r\n    delete zip;\r\n}\r\n\r\ntry\r\n{\r\n    Directory::Delete(sourcePath);\r\n}\r\ncatch(Exception^ ex)\r\n{\r\n}\r\n...\r\n\r\nCouple of notes:\r\n1) I've used 'delete zip' rather than 'zip-&gt;~ZipFile()' as this has the same effect and is more idiomatic for C++.  (I tried zip-&gt;~ZipFile() just incase, but get the same results.)\r\n2) If the zip is a single span, it deletes just fine.\r\n2a) To test, I took out the 'delete zip', and I then get the exception even for single span archives, as you might expect!\r\n3) In Windows Explorer I can not delete any of the zip fragments until the extraction application exits.\r\n\r\nSo, I was wondering if the Dispose method fails to close the zip fragments when dealing with a multi-span archive?\r\n\r\n",
    "PostedDate": "2010-05-26T09:39:21.603-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "447736",
    "ThreadId": "67678",
    "Html": "Hmmm... don't know what has happened to all the carriage returns in that post. \r\nSorry!",
    "PostedDate": "2010-05-26T09:41:42.537-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "447933",
    "ThreadId": "67678",
    "Html": "<p>I'd like you to open a new discussion, rather than resurrecting one that is 9 months old.</p>\r\n<p>Thanks.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2010-05-26T19:38:23.44-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]