ZipFile
Provides static methods for creating, extracting, and opening zip archives.
Definition
Namespace:Telerik.Windows.Zip.Extensions
Assembly:Telerik.Windows.Zip.Extensions.dll
Syntax:
public static class ZipFile
Inheritance: objectZipFile
Methods
Archives a file by compressing it using the specified compression level and adding it to the zip archive.
public static ZipArchiveEntry CreateEntryFromFile(this ZipArchive destination, string sourceFileName, string entryName, CompressionLevel compressionLevel, TimeSpan? timeout)
The zip archive to add the file to.
sourceFileNamestringThe 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.
entryNamestringThe name of the entry to create in the zip archive.
compressionLevelCompressionLevelOne of the enumeration values that indicates whether to emphasize speed or compression effectiveness when creating the entry.
timeoutTimeSpan?The time period after which the operation will be cancelled.
Returns:New entry in archive.
Archives a file by compressing it using the specified compression settings and adding it to the zip archive.
public static ZipArchiveEntry CreateEntryFromFile(this ZipArchive destination, string sourceFileName, string entryName, CompressionSettings compressionSettings, TimeSpan? timeout)
The zip archive to add the file to.
sourceFileNamestringThe 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.
entryNamestringThe name of the entry to create in the zip archive.
compressionSettingsCompressionSettingsCompression settings.
timeoutTimeSpan?The time period after which the operation will be cancelled.
Returns:New entry in archive.
Archives a file by compressing it and adding it to the zip archive.
public static ZipArchiveEntry CreateEntryFromFile(this ZipArchive destination, string sourceFileName, string entryName, TimeSpan? timeout)
The zip archive to add the file to.
sourceFileNamestringThe 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.
entryNamestringThe name of the entry to create in the zip archive.
timeoutTimeSpan?The time period after which the operation will be cancelled.
Returns:New entry in archive.
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.
public static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, CompressionLevel compressionLevel, bool includeBaseDirectory, Encoding entryNameEncoding, TimeSpan? timeout)
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.
destinationArchiveFileNamestringThe 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.
compressionLevelCompressionLevelOne of the enumeration values that indicates whether to emphasize speed or compression effectiveness when creating the entry.
includeBaseDirectoryboolTrue to include the directory name from sourceDirectoryName at the root of the archive; false to include only the contents of the directory.
entryNameEncodingEncodingThe 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.
timeoutTimeSpan?The time period after which the operation will be cancelled.
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.
public static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, CompressionLevel compressionLevel, bool includeBaseDirectory, TimeSpan? timeout)
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.
destinationArchiveFileNamestringThe 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.
compressionLevelCompressionLevelOne of the enumeration values that indicates whether to emphasize speed or compression effectiveness when creating the entry.
includeBaseDirectoryboolTrue to include the directory name from sourceDirectoryName at the root of the archive; false to include only the contents of the directory.
timeoutTimeSpan?The time period after which the operation will be cancelled.
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.
[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)
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.
destinationArchiveFileNamestringThe 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.
compressionSettingsCompressionSettingsCompression settings.
includeBaseDirectoryboolTrue to include the directory name from sourceDirectoryName at the root of the archive; false to include only the contents of the directory.
entryNameEncodingEncodingThe 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.
timeoutTimeSpan?The time period after which the operation will be cancelled.
Creates a zip archive that contains the files and directories from the specified directory.
public static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, TimeSpan? timeout)
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.
destinationArchiveFileNamestringThe 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.
timeoutTimeSpan?The time period after which the operation will be cancelled.
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.
public static void ExtractToDirectory(string sourceArchiveFileName, string destinationDirectoryName, Encoding entryNameEncoding, TimeSpan? timeout)
The path to the archive that is to be extracted.
destinationDirectoryNamestringThe 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.
entryNameEncodingEncodingThe 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.
timeoutTimeSpan?The time period after which the operation will be cancelled.
Extracts all the files in the specified zip archive to a directory on the file system.
public static void ExtractToDirectory(string sourceArchiveFileName, string destinationDirectoryName, TimeSpan? timeout)
The path to the archive that is to be extracted.
destinationDirectoryNamestringThe 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.
timeoutTimeSpan?The time period after which the operation will be cancelled.
Extracts all the files in the zip archive to a directory on the file system.
public static void ExtractToDirectory(this ZipArchive source, string destinationDirectoryName, TimeSpan? timeout)
The zip archive to extract files from.
destinationDirectoryNamestringThe 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.
timeoutTimeSpan?The time period after which the operation will be cancelled.
Extracts an entry in the zip archive to a file, and optionally overwrites an existing file that has the same name.
public static void ExtractToFile(this ZipArchiveEntry source, string destinationFileName, bool overwrite, TimeSpan? timeout)
The zip archive entry to extract a file from.
destinationFileNamestringThe 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.
overwriteboolTrue to overwrite an existing file that has the same name as the destination file; otherwise, false.
timeoutTimeSpan?The time period after which the operation will be cancelled.
Extracts an entry in the zip archive to a file.
public static void ExtractToFile(this ZipArchiveEntry source, string destinationFileName, TimeSpan? timeout)
The zip archive entry to extract a file from.
destinationFileNamestringThe 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.
timeoutTimeSpan?The time period after which the operation will be cancelled.
Opens a zip archive at the specified path and in the specified mode.
public static ZipArchive Open(string archiveFileName, ZipArchiveMode mode, Encoding entryNameEncoding)
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.
modeZipArchiveModeOne of the enumeration values that specifies the actions which are allowed on the entries in the opened archive.
entryNameEncodingEncodingThe 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:The opened zip archive.
Opens a zip archive at the specified path and in the specified mode.
public static ZipArchive Open(string archiveFileName, ZipArchiveMode mode)
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.
modeZipArchiveModeOne of the enumeration values that specifies the actions which are allowed on the entries in the opened archive.
Returns:The opened zip archive.
Opens a zip archive for reading at the specified path.
public static ZipArchive OpenRead(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:The opened zip archive.