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


Type: System.IO.Stream

The input or output stream.

Type: System.IO.Compression.ZipArchiveMode

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

Type: System.Boolean

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


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


stream is null.


mode is an invalid value.


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


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


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
© 2015 Microsoft