Open

SevenZipArchiveEntry.Open method

Opens the entry for extraction and provides a stream with entry content.

public Stream Open(string password = null)
Parameter Type Description
password String Optional password for decryption.

Return Value

The stream that represents the contents of the entry.

Exceptions

exception condition
InvalidOperationException The archive is not opened for extraction. - or - This entry is a directory.
InvalidDataException Wrong data within the entry.

Remarks

Read from the stream to get original content of file. See examples section.

Examples

Usage:

Stream decompressed = entry.Open();

.NET 4.0 and higher - use Stream.CopyTo method:

decompressed.CopyTo(httpResponse.OutputStream)

.NET 3.5 and before - copy bytes manually:

byte[] buffer = new byte[8192];
int bytesRead;
while (0 < (bytesRead = decompressed.Read(buffer, 0, buffer.Length)))
 fileStream.Write(buffer, 0, bytesRead);

See Also