Class ZipArchive
Represents a package of compressed files in the zip archive format.
Inheritance
Inherited Members
Namespace: Telerik.Windows.Zip
Assembly: Telerik.Windows.Zip.dll
Syntax
public class ZipArchive : IDisposable, INotifyPropertyChanged
Constructors
ZipArchive(Stream)
Initializes a new instance of the ZipArchive class from the specified stream.
Declaration
[Obsolete("Use the static methods instead.")]
public ZipArchive(Stream stream)
Parameters
System. The stream that contains the archive to be read. |
ZipArchive(Stream, ZipArchiveMode, Boolean, Encoding)
Initializes a new instance of the ZipArchive class.
Declaration
[Obsolete("Use the static methods instead.")]
public ZipArchive(Stream stream, ZipArchiveMode mode, bool leaveOpen, Encoding entryNameEncoding)
Parameters
System. The stream that contains the archive to be read. |
Zip One of the enumeration values that indicates whether the zip archive is used to read, create, or update entries. |
System. True to leave the stream open after the ZipArchive object is disposed; otherwise, false. |
System. 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. |
ZipArchive(Stream, ZipArchiveMode, Boolean, Encoding, CompressionSettings, EncryptionSettingsBase)
Initializes a new instance of the ZipArchive class.
Declaration
[Obsolete("Use the static methods instead.")]
public ZipArchive(Stream stream, ZipArchiveMode mode, bool leaveOpen, Encoding entryNameEncoding, CompressionSettings compressionSettings, EncryptionSettingsBase encryptionSettings)
Parameters
System. The stream that contains the archive to be read. |
Zip One of the enumeration values that indicates whether the zip archive is used to read, create, or update entries. |
System. True to leave the stream open after the ZipArchive object is disposed; otherwise, false. |
System. 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. |
Compression Compression settings. |
Encryption Encryption settings. |
Properties
Entries
Gets the collection of entries that are currently in the zip archive.
Declaration
public IEnumerable<ZipArchiveEntry> Entries { get; }
Property Value
System.
|
Exceptions
System. The zip archive does not support reading. |
System. The zip archive has been disposed. |
Invalid The zip archive is corrupt, and its entries cannot be retrieved. |
EntryNameEncoding
Gets entry name encoding.
Declaration
public Encoding EntryNameEncoding { get; }
Property Value
System.
|
Mode
Gets a value that describes the type of action the zip archive can perform on entries.
Declaration
public ZipArchiveMode Mode { get; }
Property Value
Methods
Create(Stream)
Creates a new instance of the Zip
Declaration
public static ZipArchive Create(Stream stream)
Parameters
System. The stream that contains the archive. |
Returns
Create(Stream, Encoding)
Creates a new instance of the Zip
Declaration
public static ZipArchive Create(Stream stream, Encoding entryNameEncoding)
Parameters
System. The stream that contains the archive. |
System. 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
Create(Stream, Encoding, CompressionSettings, EncryptionSettings, Boolean)
Creates a new instance of the Zip
Declaration
public static ZipArchive Create(Stream stream, Encoding entryNameEncoding, CompressionSettings compressionSettings, EncryptionSettings encryptionSettings, bool useStrictNaming = true)
Parameters
System. The stream that contains the archive. |
System. 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. |
Compression Compression settings. |
Encryption Encryption settings. |
System. 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
CreateEntry(String)
Creates an empty entry that has the specified path and entry name in the zip archive.
Declaration
public ZipArchiveEntry CreateEntry(string entryName)
Parameters
System. A path, relative to the root of the archive, that specifies the name of the entry to be created. |
Returns
Zip An empty entry in the zip archive. |
Exceptions
System. The entry name is empty. |
System. The entry name is null. |
System. The zip archive does not support writing. |
System. 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
public ZipArchiveEntry CreateEntry(string entryName, CompressionSettings settings)
Parameters
System. A path, relative to the root of the archive, that specifies the name of the entry to be created. |
Compression Compression settings. |
Returns
Zip An empty entry in the zip archive. |
Exceptions
System. The entry name is empty. |
System. The entry name is null. |
System. The zip archive does not support writing. |
System. The zip archive has been disposed. |
Dispose()
Releases the resources used by the current instance of the ZipArchive class.
Declaration
public void Dispose()
Implements
Dispose(Boolean)
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
protected virtual void Dispose(bool disposing)
Parameters
System. True to finish writing the archive and release unmanaged and managed resources; false to release only unmanaged resources. |
Finalize()
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
Declaration
protected void Finalize()
GetEntry(String)
Retrieves a wrapper for the specified entry in the zip archive.
Declaration
public ZipArchiveEntry GetEntry(string entryName)
Parameters
System. A path, relative to the root of the archive, that identifies the entry to retrieve. |
Returns
Zip A wrapper for the specified entry in the archive; null if the entry does not exist in the archive. |
Exceptions
System. The entry name is empty. |
System. The entry name is null. |
System. The zip archive does not support reading. |
System. The zip archive has been disposed. |
Invalid The zip archive is corrupt, and its entries cannot be retrieved. |
Read(Stream)
Opens an existing archive and returns a new instance of the Zip
Declaration
public static ZipArchive Read(Stream stream)
Parameters
System. The stream that contains the archive to be read. |
Returns
Read(Stream, Encoding)
Opens an existing archive and returns a new instance of the Zip
Declaration
public static ZipArchive Read(Stream stream, Encoding entryNameEncoding)
Parameters
System. The stream that contains the archive to be read. |
System. 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
Read(Stream, Encoding, CompressionSettings, DecryptionSettings, Boolean)
Opens an existing archive and returns a new instance of the Zip
Declaration
public static ZipArchive Read(Stream stream, Encoding entryNameEncoding, CompressionSettings compressionSettings, DecryptionSettings decryptionSettings, bool useStrictNaming = true)
Parameters
System. The stream that contains the archive to be read. |
System. 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. |
Compression Compression settings. |
Decryption Decryption settings. |
System. 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
Update(Stream)
Opens an existing archive for update and returns a new instance of the Zip
Declaration
public static ZipArchive Update(Stream stream)
Parameters
System. The stream that contains the archive to be read. |
Returns
Update(Stream, Encoding)
Opens an existing archive for update and returns a new instance of the Zip
Declaration
public static ZipArchive Update(Stream stream, Encoding entryNameEncoding)
Parameters
System. The stream that contains the archive to be read. |
System. 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
Update(Stream, Encoding, CompressionSettings, DecryptionSettings, Boolean)
Opens an existing archive for update and returns a new instance of the Zip
Declaration
public static ZipArchive Update(Stream stream, Encoding entryNameEncoding, CompressionSettings compressionSettings, DecryptionSettings decryptionSettings, bool useStrictNaming = true)
Parameters
System. The stream that contains the archive to be read. |
System. 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. |
Compression Compression settings. |
Decryption Decryption settings. |
System. 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
Events
PropertyChanged
Occurs when a property value changes.
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
System.
|