共用方式為


ZipArchiveEntry.ExtractToFile Method (String, Boolean)

Creates a file on the file system with the entry’s contents and the specified name. The last write time of the file is set to the entry’s last write time. This method does allows overwriting of an existing file with the same name.

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

Syntax

'Declaration
Public Sub ExtractToFile ( _
    destinationFileName As String, _
    overwrite As Boolean _
)
public void ExtractToFile(
    string destinationFileName,
    bool overwrite
)
public:
void ExtractToFile(
    String^ destinationFileName, 
    bool overwrite
)
member ExtractToFile : 
        destinationFileName:string * 
        overwrite:bool -> unit
public function ExtractToFile(
    destinationFileName : String, 
    overwrite : boolean
)

Parameters

  • destinationFileName
    Type: System.String

    The name of the file that will hold the contents of the entry. The path is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory.

Exceptions

Exception Condition
UnauthorizedAccessException

The caller does not have the required permission.

ArgumentException

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

ArgumentNullException

destinationFileName 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 path specified in destinationFileName is invalid (for example, it is on an unmapped drive).

IOException

destinationFileName exists and overwrite is false. -or- An I/O error has occurred. -or- The entry is currently open for writing. -or- The entry has been deleted from the archive.

NotSupportedException

destinationFileName is in an invalid format -or- The ZipArchive that this entry belongs to was opened in a write-only mode.

InvalidDataException

The entry is missing from the archive or is corrupt and cannot be read -or- The entry has been compressed using a compression method that is not supported.

ObjectDisposedException

The ZipArchive that this entry belongs to has been disposed.

.NET Framework Security

See Also

Reference

ZipArchiveEntry Class

ExtractToFile Overload

Microsoft.TeamFoundation.Server.Core Namespace