ZipArchive ZipArchive ZipArchive Constructors

Definition

Overloads

ZipArchive(Stream) ZipArchive(Stream) ZipArchive(Stream)

Initializes a new instance of the ZipArchive class from the specified stream.

ZipArchive(Stream, ZipArchiveMode) ZipArchive(Stream, ZipArchiveMode) ZipArchive(Stream, ZipArchiveMode)

Initializes a new instance of the ZipArchive class from the specified stream and with the specified mode.

ZipArchive(Stream, ZipArchiveMode, Boolean) ZipArchive(Stream, ZipArchiveMode, Boolean) ZipArchive(Stream, ZipArchiveMode, Boolean)

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

ZipArchive(Stream, ZipArchiveMode, Boolean, Encoding) ZipArchive(Stream, ZipArchiveMode, Boolean, Encoding) ZipArchive(Stream, ZipArchiveMode, Boolean, Encoding)

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

ZipArchive(Stream) ZipArchive(Stream) ZipArchive(Stream)

Initializes a new instance of the ZipArchive class from the specified stream.

public:
 ZipArchive(System::IO::Stream ^ stream);
public ZipArchive (System.IO.Stream stream);
new System.IO.Compression.ZipArchive : System.IO.Stream -> System.IO.Compression.ZipArchive

Parameters

stream
Stream Stream Stream

The stream that contains the archive to be read.

Exceptions

The stream is already closed or does not support reading.

The contents of the stream are not in the zip archive format.

ZipArchive(Stream, ZipArchiveMode) ZipArchive(Stream, ZipArchiveMode) ZipArchive(Stream, ZipArchiveMode)

Initializes a new instance of the ZipArchive class from the specified stream and with the specified mode.

public:
 ZipArchive(System::IO::Stream ^ stream, System::IO::Compression::ZipArchiveMode mode);
public ZipArchive (System.IO.Stream stream, System.IO.Compression.ZipArchiveMode mode);
new System.IO.Compression.ZipArchive : System.IO.Stream * System.IO.Compression.ZipArchiveMode -> System.IO.Compression.ZipArchive

Parameters

stream
Stream Stream Stream

The input or output stream.

mode
ZipArchiveMode ZipArchiveMode ZipArchiveMode

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

Exceptions

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

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.

Remarks

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.

ZipArchive(Stream, ZipArchiveMode, Boolean) ZipArchive(Stream, ZipArchiveMode, Boolean) ZipArchive(Stream, ZipArchiveMode, Boolean)

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

public:
 ZipArchive(System::IO::Stream ^ stream, System::IO::Compression::ZipArchiveMode mode, bool leaveOpen);
public ZipArchive (System.IO.Stream stream, System.IO.Compression.ZipArchiveMode mode, bool leaveOpen);
new System.IO.Compression.ZipArchive : System.IO.Stream * System.IO.Compression.ZipArchiveMode * bool -> System.IO.Compression.ZipArchive

Parameters

stream
Stream Stream Stream

The input or output stream.

mode
ZipArchiveMode ZipArchiveMode ZipArchiveMode

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

leaveOpen
Boolean Boolean Boolean

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

Exceptions

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

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.

Remarks

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.

ZipArchive(Stream, ZipArchiveMode, Boolean, Encoding) ZipArchive(Stream, ZipArchiveMode, Boolean, Encoding) ZipArchive(Stream, ZipArchiveMode, Boolean, Encoding)

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

public:
 ZipArchive(System::IO::Stream ^ stream, System::IO::Compression::ZipArchiveMode mode, bool leaveOpen, System::Text::Encoding ^ entryNameEncoding);
public ZipArchive (System.IO.Stream stream, System.IO.Compression.ZipArchiveMode mode, bool leaveOpen, System.Text.Encoding entryNameEncoding);
new System.IO.Compression.ZipArchive : System.IO.Stream * System.IO.Compression.ZipArchiveMode * bool * System.Text.Encoding -> System.IO.Compression.ZipArchive

Parameters

stream
Stream Stream Stream

The input or output stream.

mode
ZipArchiveMode ZipArchiveMode ZipArchiveMode

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

leaveOpen
Boolean Boolean Boolean

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

entryNameEncoding
Encoding Encoding Encoding

The encoding to use when reading or writing entry names in this archive. Specify a value for this parameter only when an encoding is required for interoperability with zip archive tools and libraries that do not support UTF-8 encoding for entry names.

Exceptions

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

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.

Remarks

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.

When you open a zip archive file for reading and entryNameEncoding is set to null, entry names are decoded according to the following rules:

  • When the language encoding flag (in the general-purpose bit flag of the local file header) is not set, the current system default code page is used to decode the entry name.

  • When the language encoding flag is set, UTF-8 is used to decode the entry name.

When you open a zip archive file for reading and entryNameEncoding is set to a value other than null, entry names are decoded according to the following rules:

  • When the language encoding flag is not set, the specified entryNameEncoding is used to decode the entry name.

  • When the language encoding flag is set, UTF-8 is used to decode the entry name.

When you write to archive files and entryNameEncoding is set to null, entry names are encoded according to the following rules:

  • For entry names that contain characters outside the ASCII range, the language encoding flag is set, and entry names are encoded by using UTF-8.

  • For entry names that contain only ASCII characters, the language encoding flag is not set, and entry names are encoded by using the current system default code page.

When you write to archive files and entryNameEncoding is set to a value other than null, the specified entryNameEncoding is used to encode the entry names into bytes. The language encoding flag (in the general-purpose bit flag of the local file header) is set only when the specified encoding is a UTF-8 encoding.

Applies to