C# ZipFile Open(String, ZipArchiveMode)
Description
ZipFile Open(String, ZipArchiveMode)
Opens a zip archive
at the specified path and in the specified mode.
Syntax
ZipFile.Open(String, ZipArchiveMode)
has the following syntax.
public static ZipArchive Open(
string archiveFileName,
ZipArchiveMode mode
)
Parameters
ZipFile.Open(String, ZipArchiveMode)
has the following parameters.
archiveFileName
- The path to the archive to open, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.mode
- One of the enumeration values that specifies the actions which are allowed on the entries in the opened archive.
Returns
ZipFile.Open(String, ZipArchiveMode)
method returns The opened zip archive.
Example
using System;/* w ww . ja v a 2s .c o m*/
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);
}
}
}