/// <summary> /// Method to open an existing storage from stream /// </summary> /// <param name="stream">Already opened stream with zip contents</param> /// <param name="access">File access mode for stream operations</param> /// <returns>A valid ZipArchive object</returns> public static ZipArchive Open(Stream stream, FileAccess access) { if (!stream.CanSeek && access != FileAccess.Read) { throw new InvalidOperationException("Stream cannot seek"); } ZipArchive zip = new ZipArchive(); //zip.fileName = fileName; zip.zipFileStream = stream; zip.Access = access; if (zip.ReadArchiveInfo()) { return(zip); } throw new Exception("Open the stream error!"); //throw new System.IO.InvalidDataException(); }