ZipArchive.ExtractToDirectory Method (String, String)
Extracts all of the files in the specified 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 the destinationDirectoryName as the entry has to the archive. The path is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. 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 Shared Sub ExtractToDirectory ( _
sourceArchiveFileName As String, _
destinationDirectoryName As String _
)
public static void ExtractToDirectory(
string sourceArchiveFileName,
string destinationDirectoryName
)
public:
static void ExtractToDirectory(
String^ sourceArchiveFileName,
String^ destinationDirectoryName
)
static member ExtractToDirectory :
sourceArchiveFileName:string *
destinationDirectoryName:string -> unit
public static function ExtractToDirectory(
sourceArchiveFileName : String,
destinationDirectoryName : String
)
Parameters
- sourceArchiveFileName
Type: System.String
destinationDirectoryName
Type: System.StringThe path of the directory on the file system. The directory specified must not exist, but the directory that it is contained in must exist.
Exceptions
Exception | Condition |
---|---|
ArgumentException | sourceArchive or 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 | sourceArchive or destinationDirectoryName is null. |
PathTooLongException | sourceArchive or destinationDirectoryName specifies a 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 by sourceArchive or destinationDirectoryName is invalid; for example, if it is on an unmapped drive. |
IOException | The directory specified by destinationDirectoryName already exists; or an I/O error has occurred, or an archive entry’s name is zero-length, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars; or extracting an archive entry would give you a file destination that is outside the destination directory (for example, because of 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 | sourceArchive or destinationDirectoryName is in an invalid format. |
FileNotFoundException | sourceArchive was not found. |
InvalidDataException | The archive specified by sourceArchive is not a valid ZipArchive, or 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
- 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.