共用方式為


ZipArchive Constructor (String, ZipArchiveMode)

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

Namespace:  Microsoft.TeamFoundation.Server.Core
Assembly:  Microsoft.TeamFoundation.Server.Core (in Microsoft.TeamFoundation.Server.Core.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.String

    A string specifying the path on the filesystem 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.Server.Core.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 Zip file, its entries will become accessible, 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 with the ZipArchiveMode.Create mode is more efficient when creating a new Zip file.

Exceptions

Exception Condition
ArgumentException

path is a zero-length string, contains only white space, or 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, it is on an unmapped drive).

IOException

An I/O error occurred while 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 corrupt and cannot be read. -or- mode is Update and an entry is too large to fit into memory.

.NET Framework Security

See Also

Reference

ZipArchive Class

ZipArchive Overload

Microsoft.TeamFoundation.Server.Core Namespace