C# ZipFile ExtractToDirectory(String, String)
Description
ZipFile ExtractToDirectory(String, String)
Extracts
all the files in the specified zip archive to a directory on the file system.
Syntax
ZipFile.ExtractToDirectory(String, String)
has the following syntax.
public static void ExtractToDirectory(
string sourceArchiveFileName,
string destinationDirectoryName
)
Parameters
ZipFile.ExtractToDirectory(String, String)
has the following parameters.
sourceArchiveFileName
- The path to the archive that is to be extracted.destinationDirectoryName
- 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.
Returns
ZipFile.ExtractToDirectory(String, String)
method returns
Example
This example shows how to create and extract a zip archive by using the ZipFile class.
using System;/* w ww .j a v a 2s . co m*/
using System.IO;
using System.IO.Compression;
class Program
{
static void Main(string[] args)
{
string startPath = @"c:\example\start";
string zipPath = @"c:\example\result.zip";
string extractPath = @"c:\example\extract";
ZipFile.CreateFromDirectory(startPath, zipPath);
ZipFile.ExtractToDirectory(zipPath, extractPath);
}
}