public Stream Open() { if (Archive.disposed) { throw new ObjectDisposedException("The zip archive for this entry has been disposed."); } if (openStream != null && Archive.Mode == ZipArchiveMode.Update) { throw new IOException("The entry is already currently open for writing."); } if (wasDeleted) { throw new IOException("The entry has been deleted from the archive."); } if (Archive.Mode == ZipArchiveMode.Create && openStream != null) { throw new IOException("The archive for this entry was opened with the Create mode, and this entry has already been written to."); } var entryStream = entry.OpenEntryStream(); openStream = new ZipArchiveEntryStream(this, entryStream); return(openStream); }
public MemoryStream GetUnCompressStream(SharpCompress.Archive.Zip.ZipArchiveEntry entry) { MemoryStream tempStream = new MemoryStream(); //SharpCompress.Archive.IArchiveEntryExtensions.WriteTo(entry, tempStream); using (var entryStream = entry.OpenEntryStream()) { const int bufSize = 1024 * 16;//16k byte[] buf = new byte[bufSize]; int bytesRead = 0; while ((bytesRead = entryStream.Read(buf, 0, bufSize)) > 0) { tempStream.Write(buf, 0, bytesRead); } } tempStream.Position = 0; return(tempStream); }