System.IO.Compression.ZipFile.ExtractToDirectory C# (CSharp) Méthode

ExtractToDirectory() public static méthode

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 while extracting the archive, the archive will remain partially extracted. Each entry will be extracted such that the extracted file has the same relative path to 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.
sourceArchive or destinationDirectoryName is a zero-length string, contains only white space, /// or contains one or more invalid characters as defined by InvalidPathChars. sourceArchive or destinationDirectoryName is null. 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. The path specified by sourceArchive or destinationDirectoryName is invalid, /// (for example, it is on an unmapped drive). 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 result in 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. The caller does not have the required permission. sourceArchive or destinationDirectoryName is in an invalid format. sourceArchive was not found. The archive specified by sourceArchive: Is not a valid ZipArchive /// -or- An archive entry was not found or was corrupt. -or- An archive entry has been compressed using a compression method /// that is not supported.
public static ExtractToDirectory ( string sourceArchiveFileName, string destinationDirectoryName ) : void
sourceArchiveFileName string The path to the archive on the file system that is to be extracted.
destinationDirectoryName string The path to the directory on the file system. The directory specified must not exist, but the directory that it is contained in must exist.
Résultat void
        public static void ExtractToDirectory(string sourceArchiveFileName, string destinationDirectoryName)
        {
            ExtractToDirectory(sourceArchiveFileName, destinationDirectoryName, entryNameEncoding: null);
        }

Same methods

ZipFile::ExtractToDirectory ( string sourceArchiveFileName, string destinationDirectoryName, Encoding entryNameEncoding ) : void

Usage Example

Exemple #1
0
        public static void SmartExtractFolder(string archive, string dest, bool overwrite = true)
        {
            var ext = Path.GetExtension(archive).ToLowerInvariant();

            if (ext == ".tar.gz" || ext == ".tgz")
            {
                ExtractTGZ(archive, dest);
            }
            else
            {
                ZipFile.ExtractToDirectory(archive, dest, overwrite);
            }
        }
All Usage Examples Of System.IO.Compression.ZipFile::ExtractToDirectory