Class
ZipFile

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

Definition

Namespace:Telerik.Windows.Zip.Extensions

Assembly:Telerik.Windows.Zip.Extensions.dll

Syntax:

cs-api-definition
public static class ZipFile

Inheritance: objectZipFile

Methods

CreateEntryFromFile(ZipArchive, string, string)

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

Declaration

cs-api-definition
[Obsolete("This method is obsolete. Please use ZipArchiveEntry CreateEntryFromFile(this ZipArchive destination, string sourceFileName, string entryName, TimeSpan? timeout) instead.")]
public static ZipArchiveEntry CreateEntryFromFile(this ZipArchive destination, string sourceFileName, string entryName)

Parameters

destination

ZipArchive

The zip archive to add the file to.

sourceFileName

string

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.

entryName

string

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

cs-api-definition
[Obsolete("This method is obsolete. Please use ZipArchiveEntry CreateEntryFromFile(this ZipArchive destination, string sourceFileName, string entryName, CompressionLevel compressionLevel, TimeSpan? timeout) instead.")]
public static ZipArchiveEntry CreateEntryFromFile(this ZipArchive destination, string sourceFileName, string entryName, CompressionLevel compressionLevel)

Parameters

destination

ZipArchive

The zip archive to add the file to.

sourceFileName

string

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.

entryName

string

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, CompressionLevel, TimeSpan?)

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

Declaration

cs-api-definition
public static ZipArchiveEntry CreateEntryFromFile(this ZipArchive destination, string sourceFileName, string entryName, CompressionLevel compressionLevel, TimeSpan? timeout)

Parameters

destination

ZipArchive

The zip archive to add the file to.

sourceFileName

string

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.

entryName

string

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.

timeout

TimeSpan?

The time period after which the operation will be cancelled.

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

cs-api-definition
[Obsolete("This method is obsolete. Please use ZipArchiveEntry CreateEntryFromFile(this ZipArchive destination, string sourceFileName, string entryName, CompressionSettings compressionSettings, TimeSpan? timeout) instead.")]
public static ZipArchiveEntry CreateEntryFromFile(this ZipArchive destination, string sourceFileName, string entryName, CompressionSettings compressionSettings)

Parameters

destination

ZipArchive

The zip archive to add the file to.

sourceFileName

string

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.

entryName

string

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

compressionSettings

CompressionSettings

Compression settings.

Returns

ZipArchiveEntry

New entry in archive.

CreateEntryFromFile(ZipArchive, string, string, CompressionSettings, TimeSpan?)

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

Declaration

cs-api-definition
public static ZipArchiveEntry CreateEntryFromFile(this ZipArchive destination, string sourceFileName, string entryName, CompressionSettings compressionSettings, TimeSpan? timeout)

Parameters

destination

ZipArchive

The zip archive to add the file to.

sourceFileName

string

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.

entryName

string

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

compressionSettings

CompressionSettings

Compression settings.

timeout

TimeSpan?

The time period after which the operation will be cancelled.

Returns

ZipArchiveEntry

New entry in archive.

CreateEntryFromFile(ZipArchive, string, string, TimeSpan?)

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

Declaration

cs-api-definition
public static ZipArchiveEntry CreateEntryFromFile(this ZipArchive destination, string sourceFileName, string entryName, TimeSpan? timeout)

Parameters

destination

ZipArchive

The zip archive to add the file to.

sourceFileName

string

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.

entryName

string

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

timeout

TimeSpan?

The time period after which the operation will be cancelled.

Returns

ZipArchiveEntry

New entry in archive.

CreateFromDirectory(string, string)

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

Declaration

cs-api-definition
[Obsolete("This method is obsolete. Please use CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, TimeSpan? timeout) instead.")]
public static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName)

Parameters

sourceDirectoryName

string

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.

destinationArchiveFileName

string

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

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

cs-api-definition
[Obsolete("This method is obsolete. Please use CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, CompressionLevel compressionLevel, bool includeBaseDirectory, TimeSpan? timeout) instead.")]
public static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, CompressionLevel compressionLevel, bool includeBaseDirectory)

Parameters

sourceDirectoryName

string

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.

destinationArchiveFileName

string

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.

includeBaseDirectory

bool

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, bool, 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

cs-api-definition
[Obsolete("This method is obsolete. Please use CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, CompressionLevel compressionLevel, bool includeBaseDirectory, Encoding entryNameEncoding, TimeSpan? timeout) instead.")]
public static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, CompressionLevel compressionLevel, bool includeBaseDirectory, Encoding entryNameEncoding)

Parameters

sourceDirectoryName

string

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.

destinationArchiveFileName

string

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.

includeBaseDirectory

bool

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

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.

CreateFromDirectory(string, string, CompressionLevel, bool, Encoding, TimeSpan?)

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

cs-api-definition
public static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, CompressionLevel compressionLevel, bool includeBaseDirectory, Encoding entryNameEncoding, TimeSpan? timeout)

Parameters

sourceDirectoryName

string

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.

destinationArchiveFileName

string

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.

includeBaseDirectory

bool

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

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.

timeout

TimeSpan?

The time period after which the operation will be cancelled.

CreateFromDirectory(string, string, CompressionLevel, bool, TimeSpan?)

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

cs-api-definition
public static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, CompressionLevel compressionLevel, bool includeBaseDirectory, TimeSpan? timeout)

Parameters

sourceDirectoryName

string

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.

destinationArchiveFileName

string

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.

includeBaseDirectory

bool

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

timeout

TimeSpan?

The time period after which the operation will be cancelled.

CreateFromDirectory(string, string, CompressionSettings, bool, 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

cs-api-definition
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
[Obsolete("This method is obsolete. Please use CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, CompressionSettings compressionSettings, bool includeBaseDirectory, Encoding entryNameEncoding, TimeSpan? timeout) instead.")]
public static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, CompressionSettings compressionSettings, bool includeBaseDirectory, Encoding entryNameEncoding)

Parameters

sourceDirectoryName

string

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.

destinationArchiveFileName

string

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.

includeBaseDirectory

bool

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

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.

CreateFromDirectory(string, string, CompressionSettings, bool, Encoding, TimeSpan?)

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

cs-api-definition
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
public static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, CompressionSettings compressionSettings, bool includeBaseDirectory, Encoding entryNameEncoding, TimeSpan? timeout)

Parameters

sourceDirectoryName

string

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.

destinationArchiveFileName

string

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.

includeBaseDirectory

bool

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

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.

timeout

TimeSpan?

The time period after which the operation will be cancelled.

CreateFromDirectory(string, string, TimeSpan?)

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

Declaration

cs-api-definition
public static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, TimeSpan? timeout)

Parameters

sourceDirectoryName

string

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.

destinationArchiveFileName

string

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.

timeout

TimeSpan?

The time period after which the operation will be cancelled.

ExtractToDirectory(ZipArchive, string)

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

Declaration

cs-api-definition
[Obsolete("This method is obsolete. Please use ExtractToDirectory(this ZipArchive source, string destinationDirectoryName, TimeSpan? timeout) instead.")]
public static void ExtractToDirectory(this ZipArchive source, string destinationDirectoryName)

Parameters

source

ZipArchive

The zip archive to extract files from.

destinationDirectoryName

string

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.

ExtractToDirectory(ZipArchive, string, TimeSpan?)

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

Declaration

cs-api-definition
public static void ExtractToDirectory(this ZipArchive source, string destinationDirectoryName, TimeSpan? timeout)

Parameters

source

ZipArchive

The zip archive to extract files from.

destinationDirectoryName

string

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.

timeout

TimeSpan?

The time period after which the operation will be cancelled.

ExtractToDirectory(string, string)

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

Declaration

cs-api-definition
[Obsolete("This method is obsolete. Please use ExtractToDirectory(string sourceArchiveFileName, string destinationDirectoryName, TimeSpan? timeout) instead.")]
public static void ExtractToDirectory(string sourceArchiveFileName, string destinationDirectoryName)

Parameters

sourceArchiveFileName

string

The path to the archive that is to be extracted.

destinationDirectoryName

string

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

cs-api-definition
[Obsolete("This method is obsolete. Please use ExtractToDirectory(string sourceArchiveFileName, string destinationDirectoryName, Encoding entryNameEncoding, TimeSpan? timeout) instead.")]
public static void ExtractToDirectory(string sourceArchiveFileName, string destinationDirectoryName, Encoding entryNameEncoding)

Parameters

sourceArchiveFileName

string

The path to the archive that is to be extracted.

destinationDirectoryName

string

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.

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.

ExtractToDirectory(string, string, Encoding, TimeSpan?)

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

cs-api-definition
public static void ExtractToDirectory(string sourceArchiveFileName, string destinationDirectoryName, Encoding entryNameEncoding, TimeSpan? timeout)

Parameters

sourceArchiveFileName

string

The path to the archive that is to be extracted.

destinationDirectoryName

string

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.

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.

timeout

TimeSpan?

The time period after which the operation will be cancelled.

ExtractToDirectory(string, string, TimeSpan?)

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

Declaration

cs-api-definition
public static void ExtractToDirectory(string sourceArchiveFileName, string destinationDirectoryName, TimeSpan? timeout)

Parameters

sourceArchiveFileName

string

The path to the archive that is to be extracted.

destinationDirectoryName

string

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.

timeout

TimeSpan?

The time period after which the operation will be cancelled.

ExtractToFile(ZipArchiveEntry, string)

Extracts an entry in the zip archive to a file.

Declaration

cs-api-definition
[Obsolete("This method is obsolete. Please use ExtractToFile(this ZipArchiveEntry source, string destinationFileName, TimeSpan? timeout) instead.")]
public static void ExtractToFile(this ZipArchiveEntry source, string destinationFileName)

Parameters

source

ZipArchiveEntry

The zip archive entry to extract a file from.

destinationFileName

string

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, TimeSpan?)

Extracts an entry in the zip archive to a file.

Declaration

cs-api-definition
public static void ExtractToFile(this ZipArchiveEntry source, string destinationFileName, TimeSpan? timeout)

Parameters

source

ZipArchiveEntry

The zip archive entry to extract a file from.

destinationFileName

string

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.

timeout

TimeSpan?

The time period after which the operation will be cancelled.

ExtractToFile(ZipArchiveEntry, string, bool)

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

Declaration

cs-api-definition
[Obsolete("This method is obsolete. Please use ExtractToFile(this ZipArchiveEntry source, string destinationFileName, bool overwrite, TimeSpan? timeout) instead.")]
public static void ExtractToFile(this ZipArchiveEntry source, string destinationFileName, bool overwrite)

Parameters

source

ZipArchiveEntry

The zip archive entry to extract a file from.

destinationFileName

string

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.

overwrite

bool

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

ExtractToFile(ZipArchiveEntry, string, bool, TimeSpan?)

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

Declaration

cs-api-definition
public static void ExtractToFile(this ZipArchiveEntry source, string destinationFileName, bool overwrite, TimeSpan? timeout)

Parameters

source

ZipArchiveEntry

The zip archive entry to extract a file from.

destinationFileName

string

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.

overwrite

bool

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

timeout

TimeSpan?

The time period after which the operation will be cancelled.

Open(string, ZipArchiveMode)

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

Declaration

cs-api-definition
public static ZipArchive Open(string archiveFileName, ZipArchiveMode mode)

Parameters

archiveFileName

string

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.

mode

ZipArchiveMode

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

cs-api-definition
public static ZipArchive Open(string archiveFileName, ZipArchiveMode mode, Encoding entryNameEncoding)

Parameters

archiveFileName

string

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.

mode

ZipArchiveMode

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

The opened zip archive.

OpenRead(string)

Opens a zip archive for reading at the specified path.

Declaration

cs-api-definition
public static ZipArchive OpenRead(string archiveFileName)

Parameters

archiveFileName

string

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.

In this article
DefinitionMethodsCreateEntryFromFile(ZipArchive, string, string)CreateEntryFromFile(ZipArchive, string, string, CompressionLevel)CreateEntryFromFile(ZipArchive, string, string, CompressionLevel, TimeSpan?)CreateEntryFromFile(ZipArchive, string, string, CompressionSettings)CreateEntryFromFile(ZipArchive, string, string, CompressionSettings, TimeSpan?)CreateEntryFromFile(ZipArchive, string, string, TimeSpan?)CreateFromDirectory(string, string)CreateFromDirectory(string, string, CompressionLevel, bool)CreateFromDirectory(string, string, CompressionLevel, bool, Encoding)CreateFromDirectory(string, string, CompressionLevel, bool, Encoding, TimeSpan?)CreateFromDirectory(string, string, CompressionLevel, bool, TimeSpan?)CreateFromDirectory(string, string, CompressionSettings, bool, Encoding)CreateFromDirectory(string, string, CompressionSettings, bool, Encoding, TimeSpan?)CreateFromDirectory(string, string, TimeSpan?)ExtractToDirectory(ZipArchive, string)ExtractToDirectory(ZipArchive, string, TimeSpan?)ExtractToDirectory(string, string)ExtractToDirectory(string, string, Encoding)ExtractToDirectory(string, string, Encoding, TimeSpan?)ExtractToDirectory(string, string, TimeSpan?)ExtractToFile(ZipArchiveEntry, string)ExtractToFile(ZipArchiveEntry, string, TimeSpan?)ExtractToFile(ZipArchiveEntry, string, bool)ExtractToFile(ZipArchiveEntry, string, bool, TimeSpan?)Open(string, ZipArchiveMode)Open(string, ZipArchiveMode, Encoding)OpenRead(string)
Not finding the help you need?
Contact Support