ZipArchive ZipArchive ZipArchive Constructors

定义

重载

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

从指定的流初始化 ZipArchive 类的新实例。Initializes a new instance of the ZipArchive class from the specified stream.

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

从指定的流并使用指定的模式初始化 ZipArchive 类的新实例。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)

对于指定的模式,初始化指定流上的 ZipArchive 类的新实例,并选择性地使流保持打开状态。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)

对于指定的模式,初始化指定流上的 ZipArchive 类的新实例,使用项名的指定编码,并选择性地使流保持打开状态。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)

从指定的流初始化 ZipArchive 类的新实例。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

参数

stream
Stream Stream Stream

包含待读取的存档的流。The stream that contains the archive to be read.

异常

该流已关闭或不支持读取。The stream is already closed or does not support reading.

流的内容不是 zip 存档格式。The contents of the stream are not in the zip archive format.

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

从指定的流并使用指定的模式初始化 ZipArchive 类的新实例。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

参数

stream
Stream Stream Stream

输入流或输出流。The input or output stream.

mode
ZipArchiveMode ZipArchiveMode ZipArchiveMode

一个枚举值指示 zip 存档是否用于读取、创建或更新使用。One of the enumeration values that indicates whether the zip archive is used to read, create, or update entries.

异常

流已关闭,或流的功能与模式不相匹配。The stream is already closed, or the capabilities of the stream do not match the mode.

流的内容无法被解释为 zip 存档。The contents of the stream could not be interpreted as a zip archive.

-or- modeUpdate,但存档中缺少项,或者项已损坏且无法读取。mode is Update and an entry is missing from the archive or is corrupt and cannot be read.

-or- modeUpdate,但项太大,无法装入内存。mode is Update and an entry is too large to fit into memory.

注解

如果参数设置为Read, 则流必须支持读取。 modeIf the mode parameter is set to Read, the stream must support reading. 如果参数设置为Create, 则流必须支持写入。 modeIf the mode parameter is set to Create, the stream must support writing. 如果参数设置为Update, 则流必须支持读取、写入和查找。 modeIf 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)

对于指定的模式,初始化指定流上的 ZipArchive 类的新实例,并选择性地使流保持打开状态。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

参数

stream
Stream Stream Stream

输入流或输出流。The input or output stream.

mode
ZipArchiveMode ZipArchiveMode ZipArchiveMode

一个枚举值指示 zip 存档是否用于读取、创建或更新使用。One of the enumeration values that indicates whether the zip archive is used to read, create, or update entries.

leaveOpen
Boolean Boolean Boolean

如果在释放 ZipArchive 对象后保持流处于打开状态,则为 true;否则为 falsetrue 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.

流的内容无法被解释为 zip 存档。The contents of the stream could not be interpreted as a zip archive.

- 或 --or- modeUpdate,但存档中缺少项,或者项已损坏且无法读取。mode is Update and an entry is missing from the archive or is corrupt and cannot be read.

- 或 --or- modeUpdate,但项太大,无法装入内存。mode is Update and an entry is too large to fit into memory.

注解

如果参数设置为Read, 则流必须支持读取。 modeIf the mode parameter is set to Read, the stream must support reading. 如果参数设置为Create, 则流必须支持写入。 modeIf the mode parameter is set to Create, the stream must support writing. 如果参数设置为Update, 则流必须支持读取、写入和查找。 modeIf 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)

对于指定的模式,初始化指定流上的 ZipArchive 类的新实例,使用项名的指定编码,并选择性地使流保持打开状态。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

参数

stream
Stream Stream Stream

输入流或输出流。The input or output stream.

mode
ZipArchiveMode ZipArchiveMode ZipArchiveMode

一个枚举值指示 zip 存档是否用于读取、创建或更新使用。One of the enumeration values that indicates whether the zip archive is used to read, create, or update entries.

leaveOpen
Boolean Boolean Boolean

如果在释放 ZipArchive 对象后保持流处于打开状态,则为 true;否则为 falsetrue 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. 仅当需要针对具有不支持条目名称的 UTF-8 编码的 zip 归档工具和库的互操作性进行编码时,为此参数指定值。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.

异常

流已关闭,或流的功能与模式不相匹配。The stream is already closed, or the capabilities of the stream do not match the mode.

流的内容无法被解释为 zip 存档。The contents of the stream could not be interpreted as a zip archive.

- 或 --or- modeUpdate,但存档中缺少项,或者项已损坏且无法读取。mode is Update and an entry is missing from the archive or is corrupt and cannot be read.

-or- modeUpdate,但项太大,无法装入内存。mode is Update and an entry is too large to fit into memory.

注解

如果参数设置为Read, 则流必须支持读取。 modeIf the mode parameter is set to Read, the stream must support reading. 如果参数设置为Create, 则流必须支持写入。 modeIf the mode parameter is set to Create, the stream must support writing. 如果参数设置为Update, 则流必须支持读取、写入和查找。 modeIf the mode parameter is set to Update, the stream must support reading, writing, and seeking.

当你打开要读取的 zip 存档文件并entryNameEncoding将设置为null时, 将根据以下规则对条目名称进行解码: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.

  • 如果设置了语言编码标志, 则使用 UTF-8 对条目名称进行解码。When the language encoding flag is set, UTF-8 is used to decode the entry name.

当你打开 zip 存档文件以进行读取, entryNameEncoding并将设置为之外的值null时, 将根据以下规则对条目名称进行解码: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:

  • 如果未设置语言编码标志, 则使用指定entryNameEncoding的对项名称进行解码。When the language encoding flag is not set, the specified entryNameEncoding is used to decode the entry name.

  • 如果设置了语言编码标志, 则使用 UTF-8 对条目名称进行解码。When the language encoding flag is set, UTF-8 is used to decode the entry name.

当你写入存档文件并且entryNameEncoding将设置为null时, 将根据以下规则对条目名称进行编码:When you write to archive files and entryNameEncoding is set to null, entry names are encoded according to the following rules:

  • 对于包含 ASCII 范围外的字符的条目名称, 设置语言编码标志, 并使用 UTF-8 对条目名称进行编码。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.

  • 对于仅包含 ASCII 字符的条目名称, 未设置语言编码标志, 并且通过使用当前系统默认代码页对条目名称进行编码。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.

当你写入存档文件并且entryNameEncoding将设置为之外的值null时, 将使用指定entryNameEncoding的将输入名称编码为个字节。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. 仅当指定的编码为 UTF-8 编码时, 才设置语言编码标志 (本地文件头的通用位标志)。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.

适用于