Skip to main content

How to: Unzip an Archive

  1. Call the static ZipArchive.Read method of the DevExpress.Compression.ZipArchive class. It has two overloads, so you can specify a compressed stream or a path to archive a file as the method’s argument. This method returns a ZipArchive instance that provides access to a collection of ZipItem elements using indexed notation.
  2. An archive item can be accessed using its archive path or index.
  3. You can specify the ZipArchive.Password property value, if required.
  4. For each ZipItem call the ZipItem.Extract method. It has two overloads, so you can either specify a destination stream or a destination file path.

This example illustrates how to load the zip file and extract it to the specified directory. If the target directory is not specified, the current directory is the target.

View Example

using DevExpress.Compression;

public void UnzipArchive() {
    string pathToZipArchive = "Documents\\";
    string pathToExtract = "Documents\\!Extracted";
    using (ZipArchive archive = ZipArchive.Read(pathToZipArchive)) {
        foreach (ZipItem item in archive) {