ZipArchive Constructor (Stream, ZipArchiveMode, Boolean)

.NET Framework 4.6 and 4.5

Initializes a new instance of the ZipArchive class on the specified stream for the specified mode, and optionally leaves the stream open.

Namespace:  System.IO.Compression
Assembly:  System.IO.Compression (in System.IO.Compression.dll)

public ZipArchive(
	Stream stream,
	ZipArchiveMode mode,
	bool leaveOpen
)

Parameters

stream
Type: System.IO.Stream

The input or output stream.

mode
Type: System.IO.Compression.ZipArchiveMode

One of the enumeration values that indicates whether the zip archive is used to read, create, or update entries.

leaveOpen
Type: System.Boolean

true to leave the stream open after the ZipArchive object is disposed; otherwise, false.

ExceptionCondition
ArgumentException

The stream is already closed, or the capabilities of the stream do not match the mode.

ArgumentNullException

stream is null.

ArgumentOutOfRangeException

mode is an invalid value.

InvalidDataException

The contents of the stream could not be interpreted as a zip archive.

-or-

mode is Update and an entry is missing from the archive or is corrupt and cannot be read.

-or-

mode is Update and an entry is too large to fit into memory.

If the mode parameter is set to Read, the stream must support reading. If the mode parameter is set to Create, the stream must support writing. If the mode parameter is set to Update, the stream must support reading, writing, and seeking.

.NET Framework

Supported in: 4.6, 4.5

Supported in: Windows Phone 8.1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft