Edit this page
Available for: UI for ASP.NET AJAX | UI for ASP.NET MVC | UI for WPF

Zip Extensions

In addition to the main ZipLibrary control, you could take advantage of a set of helper methods, divided in two classes, which will help you to implement your scenarios faster. All these methods are in the Telerik.Windows.Zip.Extensions.dll.

In this article you will find the classes and their members.

The ZipFile class

With the ZipFile class you could take advantage of static methods, which will give you the ability to create, extract or open zip archives with only one line of code.

  • ZipArchiveEntry CreateEntryFromFile(this ZipArchive destination, string sourceFileName, string entryName) – Archives a file by compressing it and adding it to the zip archive. It has two more overloads, which allow you to specify the CompressionLevel or CompressionSettings of the ZipEntry.

  • void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName): Creates a zip archive that contains the files and directories from the specified directory. This method has few overloads to set different settings of the entry.

  • void ExtractToDirectory(string sourceArchiveFileName, string destinationDirectoryName): Extracts all the files in the specified zip archive to a directory on the file system.

  • void ExtractToFile(this ZipArchiveEntry source, string destinationFileName): Extracts an entry in the zip archive to a file. With the additional overload you could specify whether to overwrite an existing file that has the same name as the destination file or not.

  • ZipArchive Open(string archiveFileName, ZipArchiveMode mode): Opens a zip archive at the specified path and in the specified mode. Another overload allows specifying 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 OpenRead(string archiveFileName): Opens a zip archive for reading at the specified path.

  • bool IsDirectoryEmpty(DirectoryInfo directoryInfo): Indicates whether specified directory is empty or not.

The DotNetPlatformManager class

This class implements the IPlatformManager interface, which provides platform-specific operations. In the general case you won't need to implement new platform managers, as this default implementation already take advantage of the current platform (.NET Framework) as much as possible.

Properties

  • string AltDirectorySeparatorChar: Gets a platform-specific alternate character used to separate directory levels in a path string that reflects a hierarchical file system organization.

  • Encoding DefaultEncoding: Gets default encoding for this platform.

  • string DirectorySeparatorChar: Gets a platform-specific character used to separate directory levels in a path string that reflects a hierarchical file system organization.

  • TemporaryStreamType TemporaryStreamType: Gets or sets type of the temporary stream. The default value is TemporaryStreamType.Memory.

Methods

  • stream CreateTemporaryStream(): Creates temporary stream. Stream will be used for temporary operations.

  • void DeleteTemporaryStream(Stream stream): Deletes temporary stream.

  • ICryptoProvider GetCryptoProvider(EncryptionSettings settings): Gets crypto provider initialized using given encryption settings.

  • bool IsEncodingSupported(Encoding encoding): Indicates whether specified encoding is supported for this platform. true if encoding is allowed in the ZIP file.

See Also