C# ZipFile ExtractToDirectory(String, String, Encoding)

Description

ZipFile ExtractToDirectory(String, String, Encoding) 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.

Syntax

ZipFile.ExtractToDirectory(String, String, Encoding) has the following syntax.


public static void ExtractToDirectory(
  string sourceArchiveFileName,// w w w .j av  a2s .  c o m
  string destinationDirectoryName,
  Encoding entryNameEncoding
)

Parameters

ZipFile.ExtractToDirectory(String, String, Encoding) 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.
  • entryNameEncoding - 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.

Returns

ZipFile.ExtractToDirectory(String, String, Encoding) method returns

Example


using System;//ww w .j a  va  2 s.  c  o 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,);
    }
}




















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




DeflateStream
GZipStream
ZipArchive
ZipArchiveEntry
ZipFile
ZipFileExtensions