New to Telerik Document ProcessingStart a free 30-day trial

Represents a package of compressed files in the zip archive format.

Definition

Namespace:Telerik.Windows.Zip

Assembly:Telerik.Windows.Zip.dll

Syntax:

C#
public class ZipArchive : IDisposable, INotifyPropertyChanged

Inheritance: objectZipArchive

Implements: IDisposableINotifyPropertyChanged

Events

Occurs when a property value changes.

C#
public event PropertyChangedEventHandler PropertyChanged

Implements: INotifyPropertyChanged.PropertyChanged

Methods

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.

C#
protected ~ZipArchive()

Creates a new instance of the ZipArchive class.

C#
public static ZipArchive Create(Stream stream, Encoding entryNameEncoding, CompressionSettings compressionSettings, EncryptionSettings encryptionSettings, bool useStrictNaming = true)
Parameters:streamStream

The stream that contains the archive.

entryNameEncodingEncoding

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.

compressionSettingsCompressionSettings

Compression settings.

encryptionSettingsEncryptionSettings

Encryption settings.

useStrictNamingbool

A value indicating whether the paths of the entries will be verified to be limited to relative paths that cannot traverse upwards in the file system. True by default.

Returns:

ZipArchive

Creates a new instance of the ZipArchive class.

C#
public static ZipArchive Create(Stream stream, Encoding entryNameEncoding)
Parameters:streamStream

The stream that contains the archive.

entryNameEncodingEncoding

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.

Returns:

ZipArchive

Creates a new instance of the ZipArchive class.

C#
public static ZipArchive Create(Stream stream)
Parameters:streamStream

The stream that contains the archive.

Returns:

ZipArchive

Creates an empty entry that has the specified path and entry name in the zip archive.

C#
public ZipArchiveEntry CreateEntry(string entryName, CompressionSettings settings)
Parameters:entryNamestring

A path, relative to the root of the archive, that specifies the name of the entry to be created.

settingsCompressionSettings

Compression settings.

Returns:

ZipArchiveEntry

An empty entry in the zip archive.

Exceptions:

ArgumentException

The entry name is empty.

ArgumentNullException

The entry name is null.

NotSupportedException

The zip archive does not support writing.

ObjectDisposedException

The zip archive has been disposed.

Creates an empty entry that has the specified path and entry name in the zip archive.

C#
public ZipArchiveEntry CreateEntry(string entryName)
Parameters:entryNamestring

A path, relative to the root of the archive, that specifies the name of the entry to be created.

Returns:

ZipArchiveEntry

An empty entry in the zip archive.

Exceptions:

ArgumentException

The entry name is empty.

ArgumentNullException

The entry name is null.

NotSupportedException

The zip archive does not support writing.

ObjectDisposedException

The zip archive has been disposed.

Releases the resources used by the current instance of the ZipArchive class.

C#
public void Dispose()

Implements: IDisposable.Dispose()

Called by the Dispose() and Finalize() methods to release the unmanaged resources used by the current instance of the ZipArchive class, and optionally finishes writing the archive and releases the managed resources.

C#
protected virtual void Dispose(bool disposing)
Parameters:disposingbool

True to finish writing the archive and release unmanaged and managed resources; false to release only unmanaged resources.

Retrieves a wrapper for the specified entry in the zip archive.

C#
public ZipArchiveEntry GetEntry(string entryName)
Parameters:entryNamestring

A path, relative to the root of the archive, that identifies the entry to retrieve.

Returns:

ZipArchiveEntry

A wrapper for the specified entry in the archive; null if the entry does not exist in the archive.

Exceptions:

ArgumentException

The entry name is empty.

ArgumentNullException

The entry name is null.

NotSupportedException

The zip archive does not support reading.

ObjectDisposedException

The zip archive has been disposed.

InvalidDataException

The zip archive is corrupt, and its entries cannot be retrieved.

Opens an existing archive and returns a new instance of the ZipArchive class.

C#
public static ZipArchive Read(Stream stream, Encoding entryNameEncoding, CompressionSettings compressionSettings, DecryptionSettings decryptionSettings, bool useStrictNaming = true)
Parameters:streamStream

The stream that contains the archive to be read.

entryNameEncodingEncoding

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.

compressionSettingsCompressionSettings

Compression settings.

decryptionSettingsDecryptionSettings

Decryption settings.

useStrictNamingbool

A value indicating whether the paths of the entries will be verified to be limited to relative paths that cannot traverse upwards in the file system. True by default.

Returns:

ZipArchive

Opens an existing archive and returns a new instance of the ZipArchive class.

C#
public static ZipArchive Read(Stream stream, Encoding entryNameEncoding)
Parameters:streamStream

The stream that contains the archive to be read.

entryNameEncodingEncoding

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.

Returns:

ZipArchive

Opens an existing archive and returns a new instance of the ZipArchive class.

C#
public static ZipArchive Read(Stream stream)
Parameters:streamStream

The stream that contains the archive to be read.

Returns:

ZipArchive

Opens an existing archive for update and returns a new instance of the ZipArchive class.

C#
public static ZipArchive Update(Stream stream, Encoding entryNameEncoding, CompressionSettings compressionSettings, DecryptionSettings decryptionSettings, bool useStrictNaming = true)
Parameters:streamStream

The stream that contains the archive to be read.

entryNameEncodingEncoding

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.

compressionSettingsCompressionSettings

Compression settings.

decryptionSettingsDecryptionSettings

Decryption settings.

useStrictNamingbool

A value indicating whether the paths of the entries will be verified to be limited to relative paths that cannot traverse upwards in the file system. True by default.

Returns:

ZipArchive

Opens an existing archive for update and returns a new instance of the ZipArchive class.

C#
public static ZipArchive Update(Stream stream, Encoding entryNameEncoding)
Parameters:streamStream

The stream that contains the archive to be read.

entryNameEncodingEncoding

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.

Returns:

ZipArchive

Opens an existing archive for update and returns a new instance of the ZipArchive class.

C#
public static ZipArchive Update(Stream stream)
Parameters:streamStream

The stream that contains the archive to be read.

Returns:

ZipArchive

Properties

Gets the collection of entries that are currently in the zip archive.

C#
public IEnumerable<ZipArchiveEntry> Entries { get; }
Exceptions:

NotSupportedException

The zip archive does not support reading.

ObjectDisposedException

The zip archive has been disposed.

InvalidDataException

The zip archive is corrupt, and its entries cannot be retrieved.

Gets entry name encoding.

C#
public Encoding EntryNameEncoding { get; }

Gets a value that describes the type of action the zip archive can perform on entries.

C#
public ZipArchiveMode Mode { get; }

Extension Methods