Class
ZipArchive

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

Definition

Namespace:Telerik.Windows.Zip

Assembly:Telerik.Windows.Zip.dll

Syntax:

cs-api-definition
public class ZipArchive : IDisposable, INotifyPropertyChanged

Inheritance: objectZipArchive

Implements: IDisposableINotifyPropertyChanged

Properties

Entries

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

Declaration

cs-api-definition
public IEnumerable<ZipArchiveEntry> Entries { get; }

Property Value

IEnumerable<ZipArchiveEntry>

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.

EntryNameEncoding

Gets entry name encoding.

Declaration

cs-api-definition
public Encoding EntryNameEncoding { get; }

Property Value

Encoding

Mode

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

Declaration

cs-api-definition
public ZipArchiveMode Mode { get; }

Property Value

ZipArchiveMode

Methods

Create(Stream)

Creates a new instance of the ZipArchive class.

Declaration

cs-api-definition
public static ZipArchive Create(Stream stream)

Parameters

stream

Stream

The stream that contains the archive.

Returns

ZipArchive

Create(Stream, Encoding)

Creates a new instance of the ZipArchive class.

Declaration

cs-api-definition
public static ZipArchive Create(Stream stream, Encoding entryNameEncoding)

Parameters

stream

Stream

The stream that contains the archive.

entryNameEncoding

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.

Returns

ZipArchive

Create(Stream, Encoding, CompressionSettings, EncryptionSettings, bool)

Creates a new instance of the ZipArchive class.

Declaration

cs-api-definition
public static ZipArchive Create(Stream stream, Encoding entryNameEncoding, CompressionSettings compressionSettings, EncryptionSettings encryptionSettings, bool useStrictNaming = true)

Parameters

stream

Stream

The stream that contains the archive.

entryNameEncoding

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.

compressionSettings

CompressionSettings

Compression settings.

encryptionSettings

EncryptionSettings

Encryption settings.

useStrictNaming

bool

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

CreateEntry(string)

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

Declaration

cs-api-definition
public ZipArchiveEntry CreateEntry(string entryName)

Parameters

entryName

string

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.

CreateEntry(string, CompressionSettings)

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

Declaration

cs-api-definition
public ZipArchiveEntry CreateEntry(string entryName, CompressionSettings settings)

Parameters

entryName

string

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

settings

CompressionSettings

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.

Dispose()

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

Declaration

cs-api-definition
public void Dispose()

Implements IDisposable.Dispose()

Dispose(bool)

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.

Declaration

cs-api-definition
protected virtual void Dispose(bool disposing)

Parameters

disposing

bool

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

GetEntry(string)

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

Declaration

cs-api-definition
public ZipArchiveEntry GetEntry(string entryName)

Parameters

entryName

string

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.

Read(Stream)

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

Declaration

cs-api-definition
public static ZipArchive Read(Stream stream)

Parameters

stream

Stream

The stream that contains the archive to be read.

Returns

ZipArchive

Read(Stream, Encoding)

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

Declaration

cs-api-definition
public static ZipArchive Read(Stream stream, Encoding entryNameEncoding)

Parameters

stream

Stream

The stream that contains the archive to be read.

entryNameEncoding

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.

Returns

ZipArchive

Read(Stream, Encoding, CompressionSettings, DecryptionSettings, bool)

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

Declaration

cs-api-definition
public static ZipArchive Read(Stream stream, Encoding entryNameEncoding, CompressionSettings compressionSettings, DecryptionSettings decryptionSettings, bool useStrictNaming = true)

Parameters

stream

Stream

The stream that contains the archive to be read.

entryNameEncoding

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.

compressionSettings

CompressionSettings

Compression settings.

decryptionSettings

DecryptionSettings

Decryption settings.

useStrictNaming

bool

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

Update(Stream)

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

Declaration

cs-api-definition
public static ZipArchive Update(Stream stream)

Parameters

stream

Stream

The stream that contains the archive to be read.

Returns

ZipArchive

Update(Stream, Encoding)

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

Declaration

cs-api-definition
public static ZipArchive Update(Stream stream, Encoding entryNameEncoding)

Parameters

stream

Stream

The stream that contains the archive to be read.

entryNameEncoding

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.

Returns

ZipArchive

Update(Stream, Encoding, CompressionSettings, DecryptionSettings, bool)

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

Declaration

cs-api-definition
public static ZipArchive Update(Stream stream, Encoding entryNameEncoding, CompressionSettings compressionSettings, DecryptionSettings decryptionSettings, bool useStrictNaming = true)

Parameters

stream

Stream

The stream that contains the archive to be read.

entryNameEncoding

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.

compressionSettings

CompressionSettings

Compression settings.

decryptionSettings

DecryptionSettings

Decryption settings.

useStrictNaming

bool

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

~ZipArchive()

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

Declaration

cs-api-definition
protected ~ZipArchive()

Events

PropertyChanged

Occurs when a property value changes.

Declaration

cs-api-definition
public event PropertyChangedEventHandler PropertyChanged

Event Value

PropertyChangedEventHandler

Implements INotifyPropertyChanged.PropertyChanged

Extension Methods