C# ZipFileExtensions ExtractToDirectory

Description

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

Syntax

ZipFileExtensions.ExtractToDirectory has the following syntax.


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

Parameters

ZipFileExtensions.ExtractToDirectory has the following parameters.

  • source - The zip archive to extract files from.
  • 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.

Returns

ZipFileExtensions.ExtractToDirectory method returns

Example


using System;/*from  ww w .  ja v  a2  s  . com*/
using System.IO;
using System.IO.Compression;

class Program
{
    static void Main(string[] args)
    {
        string zipPath = @"c:\users\exampleuser\start.zip";
        string extractPath = @"c:\users\exampleuser\extract";
        string newFile = @"c:\users\exampleuser\NewFile.txt";

        using (ZipArchive archive = ZipFile.Open(zipPath, ZipArchiveMode.Update))
        {
            archive.CreateEntryFromFile(newFile, "NewEntry.txt");
            archive.ExtractToDirectory(extractPath);
        } 
    }
}




















Home »
  C# Tutorial »
    System.IO.Compression »




DeflateStream
GZipStream
ZipArchive
ZipArchiveEntry
ZipFile
ZipFileExtensions