Share via


ZipArchive.ExtractToDirectory Method (String)

Extracts all of the files in the archive to a directory on the file system. The specified directory must not exist. This method will create all subdirectories and the specified directory. If there is an error when extracting the archive, the archive will remain partially extracted. Each entry will be extracted so that the extracted file has the same relative path of destinationDirectoryName as the entry has to the root of the archive. If a file to be archived has an invalid last modified time, the first datetime representable in the Zip timestamp format (midnight on January 1, 1980) will be used.

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

Syntax

'Declaration
Public Sub ExtractToDirectory ( _
    destinationDirectoryName As String _
)
public void ExtractToDirectory(
    string destinationDirectoryName
)
public:
void ExtractToDirectory(
    String^ destinationDirectoryName
)
member ExtractToDirectory : 
        destinationDirectoryName:string -> unit
public function ExtractToDirectory(
    destinationDirectoryName : String
)

Parameters

  • destinationDirectoryName
    Type: System.String

    The path of the directory on the file system. The directory specified must not exist. 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
ArgumentException

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

ArgumentNullException

destinationDirectoryName 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

The directory specified by destinationDirectoryName already exists; or an archive entry’s name is zero-length, or it contains only white space, or it contains one or more invalid characters as defined by InvalidPathChars; or extracting an archive entry would have resulted in a destination file that is outside destinationDirectoryName (for example, if the entry name contains parent directory accessors); or an archive entry has the same name as an already extracted entry from the same archive.

UnauthorizedAccessException

The caller does not have the required permission.

NotSupportedException

destinationDirectoryName is in an invalid format.

InvalidDataException

An archive entry was not found or was corrupted, or an archive entry has been compressed by using a compression method that is not supported.

.NET Framework Security

See Also

Reference

ZipArchive Class

ExtractToDirectory Overload

Microsoft.TeamFoundation.Framework.Server Namespace