Does Ionic ZipFile lock/unlock files?
<p>I am busy developing an additional module for an existing C# (4.0) application that uses Ionic Zip library to manage the data. In my module I need to load data from zip files, manipulate them, and write back again. My routine runs OK in Unit Tests, but when called from within the host application, it throws an exception reading "<em>The process cannot access the file because it is being used by another process</em>". This happens at a point when I try to call the <code>Save()</code> function of the Zip archive. </p>

<p>I checked which process actually locks the file, and it happens to be the application itself. Therefore I conclude that there might be some kind of interference with the host program: e.g. a file stream opened at some place and not closed. (BTW, are there some smart techniques to look after such places?)</p>

<p>What puzzles me is whether those ZipFile's of Ionic really lock / unlock files when dealing with files, as in the following code piece:</p>

<pre><code>ZipFile zf  = new ZipFile("test01.zip");
zf.Save();

// FileSystemTools.WhoIsLocking is a utility showing a list pf processes
// holding access to a given file
// Similar to http://stackoverflow.com/questions/1304/how-to-check-for-file-lock/20623302#20623302

List&lt;Process&gt; processes = FileSystemTools.WhoIsLocking("test01.zip");
Assert.That(processes.Count == 1);

zf.Dispose();
processes   = FileSystemTools.WhoIsLocking("test01.zip");
Assert.That(processes.Count == 0);
</code></pre>

<p>After <code>Save()</code> the number of locking processes is 1 (the running process itself), but after <code>Dispose()</code> there are none, which attests that Ionic.ZipFile obviously holds some file streams internally and manages them somehow. At other places, however, <code>Dispose()</code> has no effect: the number of locking process is not decremented. Iconic.Zip documentation is scarce and nconvincing.</p>