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)
Syntax
'Declaration
Public Sub New ( _
archiveFileName As String, _
mode As ZipArchiveMode _
)
public ZipArchive(
string archiveFileName,
ZipArchiveMode mode
)
public:
ZipArchive(
String^ archiveFileName,
ZipArchiveMode mode
)
new :
archiveFileName:string *
mode:ZipArchiveMode -> ZipArchive
public function ZipArchive(
archiveFileName : String,
mode : ZipArchiveMode
)
Parameters
archiveFileName
Type: System.StringA 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.
mode
Type: Microsoft.TeamFoundation.Framework.Server.ZipArchiveModeSee 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.
Exceptions
Exception | Condition |
---|---|
ArgumentException | path is a zero-length string, or it contains only white space, or it contains one or more invalid characters as defined by InvalidPathChars. |
ArgumentNullException | path is null. |
PathTooLongException | 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. |
DirectoryNotFoundException | The specified path is invalid; for example, if it is on an unmapped drive. |
IOException | An I/O error occurred while you are opening the file. |
UnauthorizedAccessException | path specified a directory, or the caller does not have the required permission. |
ArgumentOutOfRangeException | mode specified an invalid value. |
FileNotFoundException | The file specified in path was not found. |
NotSupportedException | path is in an invalid format. |
InvalidDataException | 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. |
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.