+
+ try {
+ zipFile = mode != ZipArchiveMode.Create && stream.Length != 0
+ ? SharpCompress.Archive.Zip.ZipArchive.Open(stream)
+ : SharpCompress.Archive.Zip.ZipArchive.Create();
+ } catch (Exception e) {
+ throw new InvalidDataException("The contents of the stream are not in the zip archive format.", e);
+ }
+
+ entries = new List<ZipArchiveEntry>();
+ if (Mode != ZipArchiveMode.Create) {
+ foreach (var entry in zipFile.Entries) {
+ var zipEntry = new ZipArchiveEntry(this, entry);
+ entries.Add(zipEntry);
+ }
+ }
+ }
+ catch {
+ if (!leaveStreamOpen)
+ stream.Dispose();
+ throw;