[
  {
    "Id": "522609",
    "ThreadId": "234862",
    "Html": "\r\n<p>After I extract a multi volume zip archive with method&nbsp;ZipEntry.Extract(baseDirectory), I can't delete the input file because it is locked by the DotNetZip library.</p>\r\n<p>I get exceptions like:</p>\r\n<p><em>The process cannot access the file 'c:\\test\\EDRM-multivolume.z01' because it is being used by another process.</em></p>\r\n<p>However the code is single threaded.&nbsp;Errors like this happen&nbsp;when a&nbsp;file is read&nbsp;via&nbsp;a file stream and this file stream isn't properly disposed. I don't think that it is related to other processes or other threads.</p>\r\n<p>How can I solve this problem?</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n",
    "PostedDate": "2010-11-16T03:41:40.67-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "522664",
    "ThreadId": "234862",
    "Html": "\r\n<p>Show your code.</p>\r\n<p>Did you use a using clause?&nbsp; That is what disposes the ZipFile object, and closes files related to it.</p>\r\n<p>&nbsp;</p>\r\n",
    "PostedDate": "2010-11-16T06:02:39.833-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "523195",
    "ThreadId": "234862",
    "Html": "\r\n<p>Here is an example, the first using(FileStream f = new FileStream) runs fine but the second&nbsp;time it returns an exception that the file can't be accessed, the extraction itself was successful:</p>\r\n<pre>            using (FileStream f = new FileStream(@&quot;c:\\test\\EDRM-multivolume.z01&quot;, FileMode.Open, FileAccess.Write)) {\r\n            }\r\n            \r\n            int counter = 0; \r\n            using (ZipFile file = new ZipFile(@&quot;c:\\test\\EDRM-multivolume.zip&quot;)) {\r\n                List entries = file.Entries.ToList();\r\n                foreach (ZipEntry entry in entries) {\r\n                    counter&#43;&#43;;\r\n                    if (!entry.IsDirectory) {\r\n                        entry.FileName = @&quot;result&quot; &#43; counter.ToString() &#43; &quot;.txt&quot;;\r\n                        entry.Extract(@&quot;C:\\testResults&quot;); \r\n                    }\r\n                }\r\n            }\r\n\r\n            using (FileStream f = new FileStream(@&quot;c:\\test\\EDRM-multivolume.z01&quot;, FileMode.Open, FileAccess.Write)) {\r\n            }\r\n</pre>\r\n<p><span style=\"font-family:Consolas; font-size:x-small\"><span style=\"font-family:Consolas; font-size:x-small\">My aim is to delete the archive after it has been extracted.\r\n</span></span></p>\r\n<p><span style=\"font-family:Consolas; font-size:x-small\"><span style=\"font-family:Consolas; font-size:x-small\">&nbsp;</span></span></p>\r\n",
    "PostedDate": "2010-11-17T05:11:06.957-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "523264",
    "ThreadId": "234862",
    "Html": "This discussion has been copied to a work item. Click <a href=\"http://dotnetzip.codeplex.com/workitem/12521\">here</a> to go to the work item and continue the discussion.",
    "PostedDate": "2010-11-17T07:30:39.513-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "523277",
    "ThreadId": "234862",
    "Html": "\r\n<p>RaymondRaymond, what you report sounds like a bug to me.</p>\r\n<p>I'll have to investigate. I don't have any good suggestions for you, right now, on how to avoid the problem.</p>\r\n<p>&nbsp;</p>\r\n",
    "PostedDate": "2010-11-17T07:44:57.34-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "523399",
    "ThreadId": "234862",
    "Html": "\r\n<p>Is it possible to extract a multi volume zip by using streams of a big concatenated file?&nbsp;</p>\r\n",
    "PostedDate": "2010-11-17T11:10:17.373-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "523522",
    "ThreadId": "234862",
    "Html": "\r\n<p>Raymond, I don't know what you mean.</p>\r\n<p>Maybe you could elaborate, or show some code illustrating what you are talking about.</p>\r\n<p>&nbsp;</p>\r\n",
    "PostedDate": "2010-11-17T15:57:15.25-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "524214",
    "ThreadId": "234862",
    "Html": "\r\n<p>Well, it is possible to extract streams. Is it possible to create a big stream that contains all the contents of all the files of the archive and to extract that stream?</p>\r\n<p>Or is&nbsp;it possible to create one big file that contains all the contents of all the files of the archive and to extract that big file?</p>\r\n<p>I understand that the order of concatanation will be important.</p>\r\n<p>&nbsp;</p>\r\n",
    "PostedDate": "2010-11-19T00:18:03.44-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "524281",
    "ThreadId": "234862",
    "Html": "\r\n<p>Sure.&nbsp; There's a method, <a href=\"http://cheeso.members.winisp.net/DotNetZipHelp/html/8e64cfe0-5dfc-2682-2c10-cb840ed3bfa1.htm\">\r\nZipEntry.Extract(stream)</a>.&nbsp; I believe you can simply call that method, for each entry in the archive, and pass the same stream. This method does not close the destination stream after extracting contents into it.&nbsp; The flow is like this:</p>\r\n<p>Open the destination stream<br>\r\nFor each entry</p>\r\n<p style=\"padding-left:30px\">extract the entry into that stream</p>\r\n<p style=\"padding-left:30px\">&nbsp;</p>\r\n<p>&nbsp;</p>\r\n",
    "PostedDate": "2010-11-19T03:45:05.973-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "524381",
    "ThreadId": "234862",
    "Html": "\r\n<p>I use C# 4.0.</p>\r\n<p>I tried this:</p>\r\n<pre>            using (MemoryStream memoryStream = new MemoryStream()) {\r\n                using (FileStream t = new FileStream(@&quot;c:\\test\\EDRM-multivolume.zip&quot;, FileMode.Open)) {\r\n                    t.CopyTo(memoryStream);\r\n                }\r\n                using (FileStream t = new FileStream(@&quot;c:\\test\\EDRM-multivolume.z01&quot;, FileMode.Open)) {\r\n                    t.CopyTo(memoryStream);\r\n                }\r\n                using (FileStream t = new FileStream(@&quot;c:\\test\\EDRM-multivolume.z02&quot;, FileMode.Open)) {\r\n                    t.CopyTo(memoryStream);\r\n                }\r\n                using (FileStream t = new FileStream(@&quot;c:\\test\\EDRM-multivolume.z03&quot;, FileMode.Open)) {\r\n                    t.CopyTo(memoryStream);\r\n                }\r\n                using (FileStream t = new FileStream(@&quot;c:\\test\\EDRM-multivolume.z04&quot;, FileMode.Open)) {\r\n                    t.CopyTo(memoryStream);\r\n                }\r\n                using (FileStream t = new FileStream(@&quot;c:\\test\\EDRM-multivolume.z05&quot;, FileMode.Open)) {\r\n                    t.CopyTo(memoryStream);\r\n                }\r\n                using (FileStream t = new FileStream(@&quot;c:\\test\\EDRM-multivolume.z06&quot;, FileMode.Open)) {\r\n                    t.CopyTo(memoryStream);\r\n                }\r\n                using (FileStream t = new FileStream(@&quot;c:\\test\\EDRM-multivolume.z07&quot;, FileMode.Open)) {\r\n                    t.CopyTo(memoryStream);\r\n                }\r\n                using (FileStream t = new FileStream(@&quot;c:\\test\\EDRM-multivolume.z08&quot;, FileMode.Open)) {\r\n                    t.CopyTo(memoryStream);\r\n                }\r\n\r\n                memoryStream.Position = 0; \r\n\r\n                using (ZipFile file = ZipFile.Read(memoryStream)) {\r\n                }\r\n            }\r\n\r\nbut I get exception:</pre>\r\n<pre>Ionic.Zip.BadReadException was unhandled<br>&nbsp; Message=&nbsp; ZipEntry::ReadHeader(): Bad signature (0x4139E2FB) at position&nbsp; 0x00000000<br>&nbsp; Source=Ionic.Zip<br>&nbsp; StackTrace:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Ionic.Zip.ZipEntry.ReadHeader(ZipEntry ze, Encoding defaultEncoding)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Ionic.Zip.ZipEntry.ReadEntry(ZipContainer zc, Boolean first)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Ionic.Zip.ZipFile.ReadIntoInstance_Orig(ZipFile zf)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Ionic.Zip.ZipFile.ReadIntoInstance(ZipFile zf)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Ionic.Zip.ZipFile.Read(Stream zipStream, TextWriter statusMessageWriter, Encoding encoding, EventHandler`1 readProgress)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Ionic.Zip.ZipFile.Read(Stream zipStream, TextWriter statusMessageWriter, Encoding encoding)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Ionic.Zip.ZipFile.Read(Stream zipStream)<br></pre>\r\n<pre>on line ZipFile.Read(memoryStream). </pre>\r\n",
    "PostedDate": "2010-11-19T08:07:14.733-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]