Jul 21, 2011 at 2:12 AM

I updated to v1.9.1.6 as I saw it fixed some memory issues but now when I try to extract to a MemoryStream I get a "Cannot access a closed Stream." error, the code worked fine in v1.9.1.5 though. I've tried it with both ZipEntry.Extract() and .ExtractWithPassword() and get the same error, I assume they use shared code. I've also tried initialising the MemoryStream with a byte[] buffer of sufficient size to uncompress the file. It definitly fails on the extract as I never get the Trace that follows.

            foreach (ZipEntry e in zip.Entries)
                Trace.TraceInformation("Document.ReadZipFile(...) zip entry " + e.FileName + ", size " + e.UncompressedSize + ", AlternateEncoding = " + e.AlternateEncoding.EncodingName);
                //byte[] bytes = new byte[e.UncompressedSize];
                //using (MemoryStream ms = new MemoryStream(bytes, true))
                using (MemoryStream ms = new MemoryStream())
                    Trace.TraceInformation("Document.ReadZipFile(...) memory stream can write = " + ms.CanWrite + ". Extract...");
                    //e.ExtractWithPassword(ms, _pw);
                    e.Password = _pw;
                    Trace.TraceInformation("Document.ReadZipFile(...) extract complete.");
Jul 21, 2011 at 3:43 AM

Just retried with and am getting the same error, I thought it was working before.

Jul 21, 2011 at 3:47 AM

I have discovered "my" problem. My ZipFile is opening a MemoryStream which I have found is being closed along the way. Sorry for the false alarm.