skip navigation
  • Product Bundles

    DevCraft

    All Telerik .NET tools and Kendo UI JavaScript components in one package. Now enhanced with:

    • NEW: Design Kits for Figma
    • Online Training
    • Document Processing Library
    • Embedded Reporting for web and desktop

    Web

    Kendo UI UI for jQuery UI for Angular UI for React UI for Vue UI for Blazor UI for ASP.NET Core UI for ASP.NET MVC UI for ASP.NET AJAX

    Mobile

    UI for .NET MAUI

    Document Management

    Telerik Document Processing

    Desktop

    UI for .NET MAUI UI for WinUI UI for WinForms UI for WPF

    Reporting

    Telerik Reporting Telerik Report Server

    Testing & Mocking

    Test Studio Test Studio Dev Edition Telerik JustMock

    CMS

    Sitefinity

    UI/UX Tools

    ThemeBuilder Design System Kit Templates and Building Blocks

    Debugging

    Fiddler Fiddler Everywhere Fiddler Classic Fiddler Everywhere Reporter FiddlerCore

    Free Tools

    VB.NET to C# Converter Testing Framework
    View all products
  • Overview
  • Demos
  • Docs & Support
  • Pricing
  • Shopping cart
    • Account Overview
    • Your Licenses
    • Downloads
    • Support Center
    • Forum Profile
    • Payment Methods
    • Edit Profile
    • Log out
  • Login
  • Contact Us
  • Try now

Class ZipArchive

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

Inheritance
System.Object
ZipArchive
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
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.IO.Stream stream

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.IO.Stream stream

The stream that contains the archive to be read.

ZipArchiveMode mode

One of the enumeration values that indicates whether the zip archive is used to read, create, or update entries.

System.Boolean leaveOpen

True to leave the stream open after the ZipArchive object is disposed; otherwise, false.

System.Text.Encoding entryNameEncoding

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.IO.Stream stream

The stream that contains the archive to be read.

ZipArchiveMode mode

One of the enumeration values that indicates whether the zip archive is used to read, create, or update entries.

System.Boolean leaveOpen

True to leave the stream open after the ZipArchive object is disposed; otherwise, false.

System.Text.Encoding entryNameEncoding

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.

EncryptionSettingsBase encryptionSettings

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.Collections.Generic.IEnumerable<ZipArchiveEntry>

Exceptions
System.NotSupportedException

The zip archive does not support reading.

System.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
public Encoding EntryNameEncoding { get; }
Property Value
System.Text.Encoding

Mode

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

Declaration
public ZipArchiveMode Mode { get; }
Property Value
ZipArchiveMode

Methods

Create(Stream)

Creates a new instance of the ZipArchive class.

Declaration
public static ZipArchive Create(Stream stream)
Parameters
System.IO.Stream stream

The stream that contains the archive.

Returns
ZipArchive

Create(Stream, Encoding)

Creates a new instance of the ZipArchive class.

Declaration
public static ZipArchive Create(Stream stream, Encoding entryNameEncoding)
Parameters
System.IO.Stream stream

The stream that contains the archive.

System.Text.Encoding entryNameEncoding

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, Boolean)

Creates a new instance of the ZipArchive class.

Declaration
public static ZipArchive Create(Stream stream, Encoding entryNameEncoding, CompressionSettings compressionSettings, EncryptionSettings encryptionSettings, bool useStrictNaming = true)
Parameters
System.IO.Stream stream

The stream that contains the archive.

System.Text.Encoding entryNameEncoding

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.

System.Boolean useStrictNaming

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
public ZipArchiveEntry CreateEntry(string entryName)
Parameters
System.String entryName

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
System.ArgumentException

The entry name is empty.

System.ArgumentNullException

The entry name is null.

System.NotSupportedException

The zip archive does not support writing.

System.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
public ZipArchiveEntry CreateEntry(string entryName, CompressionSettings settings)
Parameters
System.String entryName

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

CompressionSettings settings

Compression settings.

Returns
ZipArchiveEntry

An empty entry in the zip archive.

Exceptions
System.ArgumentException

The entry name is empty.

System.ArgumentNullException

The entry name is null.

System.NotSupportedException

The zip archive does not support writing.

System.ObjectDisposedException

The zip archive has been disposed.

Dispose()

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

Declaration
public void Dispose()
Implements
System.IDisposable.Dispose()

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.Boolean disposing

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.String entryName

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
System.ArgumentException

The entry name is empty.

System.ArgumentNullException

The entry name is null.

System.NotSupportedException

The zip archive does not support reading.

System.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
public static ZipArchive Read(Stream stream)
Parameters
System.IO.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
public static ZipArchive Read(Stream stream, Encoding entryNameEncoding)
Parameters
System.IO.Stream stream

The stream that contains the archive to be read.

System.Text.Encoding entryNameEncoding

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, Boolean)

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

Declaration
public static ZipArchive Read(Stream stream, Encoding entryNameEncoding, CompressionSettings compressionSettings, DecryptionSettings decryptionSettings, bool useStrictNaming = true)
Parameters
System.IO.Stream stream

The stream that contains the archive to be read.

System.Text.Encoding entryNameEncoding

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.

System.Boolean useStrictNaming

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
public static ZipArchive Update(Stream stream)
Parameters
System.IO.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
public static ZipArchive Update(Stream stream, Encoding entryNameEncoding)
Parameters
System.IO.Stream stream

The stream that contains the archive to be read.

System.Text.Encoding entryNameEncoding

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, Boolean)

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

Declaration
public static ZipArchive Update(Stream stream, Encoding entryNameEncoding, CompressionSettings compressionSettings, DecryptionSettings decryptionSettings, bool useStrictNaming = true)
Parameters
System.IO.Stream stream

The stream that contains the archive to be read.

System.Text.Encoding entryNameEncoding

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.

System.Boolean useStrictNaming

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

Events

PropertyChanged

Occurs when a property value changes.

Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
System.ComponentModel.PropertyChangedEventHandler

Extension Methods

ZipFile.CreateEntryFromFile(ZipArchive, String, String)
ZipFile.CreateEntryFromFile(ZipArchive, String, String, CompressionLevel)
ZipFile.CreateEntryFromFile(ZipArchive, String, String, CompressionSettings)
ZipFile.ExtractToDirectory(ZipArchive, String)
Getting Started
  • Getting Started
Support Resources
  • Documentation
Community
  • Forums
  • Blogs
  • Document Processing Feedback Portal

Copyright © 2018 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.