public Stream GetStreamFromReader(IEntry entry) { SharpCompress.Readers.Zip.ZipReader rd = null; try { rd = SharpCompress.Readers.Zip.ZipReader.Open(m_stream); while (rd.MoveToNextEntry()) { if (entry.Key == rd.Entry.Key) { return(new StreamWrapper(rd.OpenEntryStream(), stream => { rd.Dispose(); })); } } throw new Exception(string.Format("Stream not found: {0}", entry.Key)); } catch { if (rd != null) { rd.Dispose(); } throw; } }
public Stream GetStreamFromReader(IEntry entry) { Stream fs = null; SharpCompress.Readers.Zip.ZipReader rd = null; try { fs = new System.IO.FileStream(m_filename, FileMode.Open, FileAccess.Read, FileShare.Read); rd = SharpCompress.Readers.Zip.ZipReader.Open(fs); while (rd.MoveToNextEntry()) { if (entry.Key == rd.Entry.Key) { return(new StreamWrapper(rd.OpenEntryStream(), stream => { rd.Dispose(); fs.Dispose(); })); } } throw new Exception(string.Format("Stream not found: {0}", entry.Key)); } catch { if (rd != null) { rd.Dispose(); } if (fs != null) { fs.Dispose(); } throw; } }