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 ZipFile

Provides static methods for creating, extracting, and opening zip archives.

Inheritance
System.Object
ZipFile
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.Extensions
Assembly: Telerik.Windows.Zip.Extensions.dll

Syntax

public static class ZipFile

Methods

CreateEntryFromFile(ZipArchive, String, String)

Archives a file by compressing it and adding it to the zip archive.

Declaration
public static ZipArchiveEntry CreateEntryFromFile(this ZipArchive destination, string sourceFileName, string entryName)
Parameters
ZipArchive destination

The zip archive to add the file to.

System.String sourceFileName

The path to the file to be archived. You can specify either a relative or an absolute path. A relative path is interpreted as relative to the current working directory.

System.String entryName

The name of the entry to create in the zip archive.

Returns
ZipArchiveEntry

New entry in archive.

CreateEntryFromFile(ZipArchive, String, String, CompressionLevel)

Archives a file by compressing it using the specified compression level and adding it to the zip archive.

Declaration
public static ZipArchiveEntry CreateEntryFromFile(this ZipArchive destination, string sourceFileName, string entryName, CompressionLevel compressionLevel)
Parameters
ZipArchive destination

The zip archive to add the file to.

System.String sourceFileName

The path to the file to be archived. You can specify either a relative or an absolute path. A relative path is interpreted as relative to the current working directory.

System.String entryName

The name of the entry to create in the zip archive.

CompressionLevel compressionLevel

One of the enumeration values that indicates whether to emphasize speed or compression effectiveness when creating the entry.

Returns
ZipArchiveEntry

New entry in archive.

CreateEntryFromFile(ZipArchive, String, String, CompressionSettings)

Archives a file by compressing it using the specified compression settings and adding it to the zip archive.

Declaration
public static ZipArchiveEntry CreateEntryFromFile(this ZipArchive destination, string sourceFileName, string entryName, CompressionSettings compressionSettings)
Parameters
ZipArchive destination

The zip archive to add the file to.

System.String sourceFileName

The path to the file to be archived. You can specify either a relative or an absolute path. A relative path is interpreted as relative to the current working directory.

System.String entryName

The name of the entry to create in the zip archive.

CompressionSettings compressionSettings

Compression settings.

Returns
ZipArchiveEntry

New entry in archive.

CreateFromDirectory(String, String)

Creates a zip archive that contains the files and directories from the specified directory.

Declaration
public static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName)
Parameters
System.String sourceDirectoryName

The path to the directory to be archived, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

System.String destinationArchiveFileName

The path of the archive to be created, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

CreateFromDirectory(String, String, CompressionLevel, Boolean)

Creates a zip archive that contains the files and directories from the specified directory, uses the specified compression level, and optionally includes the base directory.

Declaration
public static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, CompressionLevel compressionLevel, bool includeBaseDirectory)
Parameters
System.String sourceDirectoryName

The path to the directory to be archived, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

System.String destinationArchiveFileName

The path of the archive to be created, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

CompressionLevel compressionLevel

One of the enumeration values that indicates whether to emphasize speed or compression effectiveness when creating the entry.

System.Boolean includeBaseDirectory

True to include the directory name from sourceDirectoryName at the root of the archive; false to include only the contents of the directory.

CreateFromDirectory(String, String, CompressionLevel, Boolean, Encoding)

Creates a zip archive that contains the files and directories from the specified directory, uses the specified compression level, and optionally includes the base directory.

Declaration
public static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, CompressionLevel compressionLevel, bool includeBaseDirectory, Encoding entryNameEncoding)
Parameters
System.String sourceDirectoryName

The path to the directory to be archived, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

System.String destinationArchiveFileName

The path of the archive to be created, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

CompressionLevel compressionLevel

One of the enumeration values that indicates whether to emphasize speed or compression effectiveness when creating the entry.

System.Boolean includeBaseDirectory

True to include the directory name from sourceDirectoryName at the root of the archive; false to include only the contents of the directory.

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.

CreateFromDirectory(String, String, CompressionSettings, Boolean, Encoding)

Creates a zip archive that contains the files and directories from the specified directory, uses the specified compression settings, and optionally includes the base directory.

Declaration
public static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, CompressionSettings compressionSettings, bool includeBaseDirectory, Encoding entryNameEncoding)
Parameters
System.String sourceDirectoryName

The path to the directory to be archived, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

System.String destinationArchiveFileName

The path of the archive to be created, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

CompressionSettings compressionSettings

Compression settings.

System.Boolean includeBaseDirectory

True to include the directory name from sourceDirectoryName at the root of the archive; false to include only the contents of the directory.

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.

ExtractToDirectory(String, String)

Extracts all the files in the specified zip archive to a directory on the file system.

Declaration
public static void ExtractToDirectory(string sourceArchiveFileName, string destinationDirectoryName)
Parameters
System.String sourceArchiveFileName

The path to the archive that is to be extracted.

System.String destinationDirectoryName

The path to the directory in which to place the extracted files, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

ExtractToDirectory(String, String, Encoding)

Extracts all the files in the specified zip archive to a directory on the file system and uses the specified character encoding for entry names.

Declaration
public static void ExtractToDirectory(string sourceArchiveFileName, string destinationDirectoryName, Encoding entryNameEncoding)
Parameters
System.String sourceArchiveFileName

The path to the archive that is to be extracted.

System.String destinationDirectoryName

The path to the directory in which to place the extracted files, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

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.

ExtractToDirectory(ZipArchive, String)

Extracts all the files in the zip archive to a directory on the file system.

Declaration
public static void ExtractToDirectory(this ZipArchive source, string destinationDirectoryName)
Parameters
ZipArchive source

The zip archive to extract files from.

System.String destinationDirectoryName

The path to the directory to place the extracted files in. You can specify either a relative or an absolute path. A relative path is interpreted as relative to the current working directory.

ExtractToFile(ZipArchiveEntry, String)

Extracts an entry in the zip archive to a file.

Declaration
public static void ExtractToFile(this ZipArchiveEntry source, string destinationFileName)
Parameters
ZipArchiveEntry source

The zip archive entry to extract a file from.

System.String destinationFileName

The path of the file to create from the contents of the entry. You can specify either a relative or an absolute path. A relative path is interpreted as relative to the current working directory.

ExtractToFile(ZipArchiveEntry, String, Boolean)

Extracts an entry in the zip archive to a file, and optionally overwrites an existing file that has the same name.

Declaration
public static void ExtractToFile(this ZipArchiveEntry source, string destinationFileName, bool overwrite)
Parameters
ZipArchiveEntry source

The zip archive entry to extract a file from.

System.String destinationFileName

The path of the file to create from the contents of the entry. You can specify either a relative or an absolute path. A relative path is interpreted as relative to the current working directory.

System.Boolean overwrite

True to overwrite an existing file that has the same name as the destination file; otherwise, false.

Open(String, ZipArchiveMode)

Opens a zip archive at the specified path and in the specified mode.

Declaration
public static ZipArchive Open(string archiveFileName, ZipArchiveMode mode)
Parameters
System.String archiveFileName

The path to the archive to open, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

ZipArchiveMode mode

One of the enumeration values that specifies the actions which are allowed on the entries in the opened archive.

Returns
ZipArchive

The opened zip archive.

Open(String, ZipArchiveMode, Encoding)

Opens a zip archive at the specified path and in the specified mode.

Declaration
public static ZipArchive Open(string archiveFileName, ZipArchiveMode mode, Encoding entryNameEncoding)
Parameters
System.String archiveFileName

The path to the archive to open, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

ZipArchiveMode mode

One of the enumeration values that specifies the actions which are allowed on the entries in the opened 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

The opened zip archive.

OpenRead(String)

Opens a zip archive for reading at the specified path.

Declaration
public static ZipArchive OpenRead(string archiveFileName)
Parameters
System.String archiveFileName

The path to the archive to open, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

Returns
ZipArchive

The opened zip archive.

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.