ZipArchive Constructor (String, ZipArchiveMode)

Opens a ZipArchive on the specified path in the specified ZipArchiveMode mode.

Namespace:  Microsoft.TeamFoundation.Framework.Server
Assembly:  Microsoft.TeamFoundation.Framework.Server (in Microsoft.TeamFoundation.Framework.Server.dll)

public ZipArchive(
	string archiveFileName,
	ZipArchiveMode mode


Type: System.String

A string specifying the path on the file system to open the archive on. The path is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory.

Type: Microsoft.TeamFoundation.Framework.Server.ZipArchiveMode

See the description of the ZipArchiveMode enum. If Read is specified, the file is opened with System.IO.FileMode.Open, and will throw a FileNotFoundException if the file does not exist. If Create is specified, the file is opened with System.IO.FileMode.CreateNew, and will throw a System.IO.IOException if the file already exists. If Update is specified, the file is opened with System.IO.FileMode.OpenOrCreate. If the file exists and is a Zip file, its entries will become available, and may be modified, and new entries may be created. If the file exists and is not a Zip file, a ZipArchiveException will be thrown. If the file exists and is empty or does not exist, a new Zip file will be created. Note that creating a Zip file by using the ZipArchiveMode.Create mode is more efficient when you are creating a new Zip file.


path is a zero-length string, or it contains only white space, or it contains one or more invalid characters as defined by InvalidPathChars.


path is null.


The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.


The specified path is invalid; for example, if it is on an unmapped drive.


An I/O error occurred while you are opening the file.


path specified a directory, or the caller does not have the required permission.


mode specified an invalid value.


The file specified in path was not found.


path is in an invalid format.


The specified file could not be interpreted as a Zip file, or mode is Update and an entry is missing from the archive or is corrupted and cannot be read, or mode is Update and an entry is too large to fit into memory.