System.IO.Compression.ZipArchive.ZipArchive C# (CSharp) Method

ZipArchive() public method

Initializes a new instance of ZipArchive on the given stream in the specified mode, specifying whether to leave the stream open.
The stream is already closed. -or- mode is incompatible with the capabilities of the stream. The stream is null. mode specified an invalid value. The contents of the stream could not be interpreted as a Zip file. -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 a Unicode encoding other than UTF-8 is specified for the entryNameEncoding.
public ZipArchive ( Stream stream, ZipArchiveMode mode, bool leaveOpen, Encoding entryNameEncoding ) : System.Collections.Generic
stream Stream The input or output stream.
mode ZipArchiveMode See the description of the ZipArchiveMode enum. Read requires the stream to support reading, Create requires the stream to support writing, and Update requires the stream to support reading, writing, and seeking.
leaveOpen bool true to leave the stream open upon disposing the ZipArchive, otherwise false.
entryNameEncoding Encoding The encoding to use when reading or writing entry names in this ZipArchive. /// /// NOTE: Specifying this parameter to values other than null is discouraged. /// However, this may be necessary for interoperability with ZIP archive tools and libraries that do not correctly support /// UTF-8 encoding for entry names.
/// This value is used as follows:
/// Reading (opening) ZIP archive files: /// If entryNameEncoding is not specified (== null): /// /// For entries where the language encoding flag (EFS) in the general purpose bit flag of the local file header is not set, /// use the current system default code page (Encoding.Default) in order to decode the entry name. /// For entries where the language encoding flag (EFS) in the general purpose bit flag of the local file header is set, /// use UTF-8 (Encoding.UTF8) in order to decode the entry name. /// /// If entryNameEncoding is specified (!= null): /// /// For entries where the language encoding flag (EFS) in the general purpose bit flag of the local file header is not set, /// use the specified entryNameEncoding in order to decode the entry name. /// For entries where the language encoding flag (EFS) in the general purpose bit flag of the local file header is set, /// use UTF-8 (Encoding.UTF8) in order to decode the entry name. /// /// Writing (saving) ZIP archive files: /// If entryNameEncoding is not specified (== null): /// /// For entry names that contain characters outside the ASCII range, /// the language encoding flag (EFS) will be set in the general purpose bit flag of the local file header, /// and UTF-8 (Encoding.UTF8) will be used in order to encode the entry name into bytes. /// For entry names that do not contain characters outside the ASCII range, /// the language encoding flag (EFS) will not be set in the general purpose bit flag of the local file header, /// and the current system default code page (Encoding.Default) will be used to encode the entry names into bytes. /// /// If entryNameEncoding is specified (!= null): /// /// The specified entryNameEncoding will always be used to encode the entry names into bytes. /// The language encoding flag (EFS) in the general purpose bit flag of the local file header will be set if and only /// if the specified entryNameEncoding is a UTF-8 encoding. /// /// Note that Unicode encodings other than UTF-8 may not be currently used for the entryNameEncoding, /// otherwise an is thrown. ///
return System.Collections.Generic
        public ZipArchive(Stream stream, ZipArchiveMode mode, bool leaveOpen, Encoding entryNameEncoding)
        {
            if (stream == null)
                throw new ArgumentNullException(nameof(stream));

            Contract.EndContractBlock();

            this.EntryNameEncoding = entryNameEncoding;
            this.Init(stream, mode, leaveOpen);
        }

Same methods

ZipArchive::ZipArchive ( System stream )
ZipArchive::ZipArchive ( System stream, System mode )
ZipArchive::ZipArchive ( System stream, System mode, bool leaveOpen )
ZipArchive::ZipArchive ( System stream, System mode, bool leaveOpen, System entryNameEncoding )
ZipArchive::ZipArchive ( Stream stream ) : System.Collections.Generic
ZipArchive::ZipArchive ( Stream stream, ZipArchiveMode mode ) : System.Collections.Generic
ZipArchive::ZipArchive ( Stream stream, ZipArchiveMode mode, bool leaveOpen ) : System.Collections.Generic