C# Class System.IO.Compression.ZipArchive

Inheritance: IDisposable
Exibir arquivo Open project: dotnet/corefx Class Usage Examples

Public Properties

Property Type Description
_forceZip64 bool

Private Properties

Property Type Description
AcquireArchiveStream void
AddEntry void
CloseStreams void
DoCreateEntry ZipArchiveEntry
EnsureCentralDirectoryRead void
Init void
IsStillArchiveStreamOwner bool
ReadCentralDirectory void
ReadEndOfCentralDirectory void
ReleaseArchiveStream void
RemoveEntry void
ThrowIfDisposed void
WriteArchiveEpilogue void
WriteFile void

Public Methods

Method Description
CreateEntry ( string entryName ) : System.IO.Compression.ZipArchiveEntry
CreateEntry ( string entryName, System compressionLevel ) : System.IO.Compression.ZipArchiveEntry
CreateEntry ( string entryName ) : ZipArchiveEntry

Creates an empty entry in the Zip archive with the specified entry name. There are no restrictions on the names of entries. The last write time of the entry is set to the current time. If an entry with the specified name already exists in the archive, a second entry will be created that has an identical name. Since no CompressionLevel is specified, the default provided by the implementation of the underlying compression algorithm will be used; the ZipArchive will not impose its own default. (Currently, the underlying compression algorithm is provided by the System.IO.Compression.DeflateStream class.)

CreateEntry ( string entryName, CompressionLevel compressionLevel ) : ZipArchiveEntry

Creates an empty entry in the Zip archive with the specified entry name. There are no restrictions on the names of entries. The last write time of the entry is set to the current time. If an entry with the specified name already exists in the archive, a second entry will be created that has an identical name.

Dispose ( ) : void
GetEntry ( string entryName ) : System.IO.Compression.ZipArchiveEntry
GetEntry ( string entryName ) : ZipArchiveEntry

Retrieves a wrapper for the file entry in the archive with the specified name. Names are compared using ordinal comparison. If there are multiple entries in the archive with the specified name, the first one found will be returned.

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

Initializes a new instance of ZipArchive on the given stream for reading.

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

Initializes a new instance of ZipArchive on the given stream in the specified mode.

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

Initializes a new instance of ZipArchive on the given stream in the specified mode, specifying whether to leave the stream open.

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

Initializes a new instance of ZipArchive on the given stream in the specified mode, specifying whether to leave the stream open.

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Private Methods

Method Description
AcquireArchiveStream ( ZipArchiveEntry entry ) : void
AddEntry ( ZipArchiveEntry entry ) : void
CloseStreams ( ) : void
DoCreateEntry ( string entryName, CompressionLevel compressionLevel ) : ZipArchiveEntry
EnsureCentralDirectoryRead ( ) : void
Init ( Stream stream, ZipArchiveMode mode, bool leaveOpen ) : void
IsStillArchiveStreamOwner ( ZipArchiveEntry entry ) : bool
ReadCentralDirectory ( ) : void
ReadEndOfCentralDirectory ( ) : void
ReleaseArchiveStream ( ZipArchiveEntry entry ) : void
RemoveEntry ( ZipArchiveEntry entry ) : void
ThrowIfDisposed ( ) : void
WriteArchiveEpilogue ( long startOfCentralDirectory, long sizeOfCentralDirectory ) : void
WriteFile ( ) : void

Method Details

CreateEntry() public method

public CreateEntry ( string entryName ) : System.IO.Compression.ZipArchiveEntry
entryName string
return System.IO.Compression.ZipArchiveEntry

CreateEntry() public method

public CreateEntry ( string entryName, System compressionLevel ) : System.IO.Compression.ZipArchiveEntry
entryName string
compressionLevel System
return System.IO.Compression.ZipArchiveEntry

CreateEntry() public method

Creates an empty entry in the Zip archive with the specified entry name. There are no restrictions on the names of entries. The last write time of the entry is set to the current time. If an entry with the specified name already exists in the archive, a second entry will be created that has an identical name. Since no CompressionLevel is specified, the default provided by the implementation of the underlying compression algorithm will be used; the ZipArchive will not impose its own default. (Currently, the underlying compression algorithm is provided by the System.IO.Compression.DeflateStream class.)
entryName is a zero-length string. entryName is null. The ZipArchive does not support writing. The ZipArchive has already been closed.
public CreateEntry ( string entryName ) : ZipArchiveEntry
entryName string A path relative to the root of the archive, indicating the name of the entry to be created.
return ZipArchiveEntry

CreateEntry() public method

Creates an empty entry in the Zip archive with the specified entry name. There are no restrictions on the names of entries. The last write time of the entry is set to the current time. If an entry with the specified name already exists in the archive, a second entry will be created that has an identical name.
entryName is a zero-length string. entryName is null. The ZipArchive does not support writing. The ZipArchive has already been closed.
public CreateEntry ( string entryName, CompressionLevel compressionLevel ) : ZipArchiveEntry
entryName string A path relative to the root of the archive, indicating the name of the entry to be created.
compressionLevel CompressionLevel The level of the compression (speed/memory vs. compressed size trade-off).
return ZipArchiveEntry

Dispose() public method

public Dispose ( ) : void
return void

Dispose() protected method

protected Dispose ( bool disposing ) : void
disposing bool
return void

GetEntry() public method

public GetEntry ( string entryName ) : System.IO.Compression.ZipArchiveEntry
entryName string
return System.IO.Compression.ZipArchiveEntry

GetEntry() public method

Retrieves a wrapper for the file entry in the archive with the specified name. Names are compared using ordinal comparison. If there are multiple entries in the archive with the specified name, the first one found will be returned.
entryName is a zero-length string. entryName is null. The ZipArchive does not support reading. The ZipArchive has already been closed. The Zip archive is corrupt and the entries cannot be retrieved.
public GetEntry ( string entryName ) : ZipArchiveEntry
entryName string A path relative to the root of the archive, identifying the desired entry.
return ZipArchiveEntry

ZipArchive() public method

public ZipArchive ( System stream )
stream System

ZipArchive() public method

public ZipArchive ( System stream, System mode )
stream System
mode System

ZipArchive() public method

public ZipArchive ( System stream, System mode, bool leaveOpen )
stream System
mode System
leaveOpen bool

ZipArchive() public method

public ZipArchive ( System stream, System mode, bool leaveOpen, System entryNameEncoding )
stream System
mode System
leaveOpen bool
entryNameEncoding System

ZipArchive() public method

Initializes a new instance of ZipArchive on the given stream for reading.
The stream is already closed or does not support reading. The stream is null. The contents of the stream could not be interpreted as a Zip archive.
public ZipArchive ( Stream stream ) : System.Collections.Generic
stream Stream The stream containing the archive to be read.
return System.Collections.Generic

ZipArchive() public method

Initializes a new instance of ZipArchive on the given stream in the specified mode.
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.
public ZipArchive ( Stream stream, ZipArchiveMode mode ) : 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.
return System.Collections.Generic

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.
public ZipArchive ( Stream stream, ZipArchiveMode mode, bool leaveOpen ) : 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.
return System.Collections.Generic

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

Property Details

_forceZip64 public_oe property

public bool _forceZip64
return bool