ZipFile Class
Provides static methods for creating, extracting, and opening zip archives.
Namespace: System.IO.Compression
Assembly: System.IO.Compression.FileSystem (in System.IO.Compression.FileSystem.dll)
The ZipFile type exposes the following members.
| Name | Description | |
|---|---|---|
![]() ![]() | CreateFromDirectory(String, String) | Creates a zip archive that contains the files and directories from the specified directory. |
![]() ![]() | CreateFromDirectory(String, String, CompressionLevel, Boolean) | Creates a zip archive that contains the files and directories from the specified directory, uses the specified compression level, and optionally includes the base directory. |
![]() ![]() | CreateFromDirectory(String, String, CompressionLevel, Boolean, Encoding) | Creates a zip archive that contains the files and directories from the specified directory, uses the specified compression level and character encoding for entry names, and optionally includes the base directory. |
![]() ![]() | ExtractToDirectory(String, String) | Extracts all the files in the specified zip archive to a directory on the file system. |
![]() ![]() | ExtractToDirectory(String, String, Encoding) | Extracts all the files in the specified zip archive to a directory on the file system and uses the specified character encoding for entry names. |
![]() ![]() | Open(String, ZipArchiveMode) | Opens a zip archive at the specified path and in the specified mode. |
![]() ![]() | Open(String, ZipArchiveMode, Encoding) | Opens a zip archive at the specified path, in the specified mode, and by using the specified character encoding for entry names. |
![]() ![]() | OpenRead | Opens a zip archive for reading at the specified path. |
The ZipFile class provides convenient static methods for working with zip archives. To use these methods, you must reference the System.IO.Compression.FileSystem assembly in your project. The System.IO.Compression.FileSystem assembly is not available for Windows Store apps. Therefore, the ZipFile class and ZipFileExtensions class (which is also in the System.IO.Compression.FileSystem assembly) are not available in Windows Store apps. In Windows Store apps, you work with compressed files by using the methods in the ZipArchive, ZipArchiveEntry, DeflateStream, and GZipStream classes.
This example shows how to create and extract a zip archive by using the ZipFile class. It compresses the contents of a folder into a zip archive, and then extracts that content to a new folder. To use the ZipFile class, you must reference the System.IO.Compression.FileSystem assembly in your project.
Imports System.IO Imports System.IO.Compression Module Module1 Sub Main() Dim startPath As String = "c:\example\start" Dim zipPath As String = "c:\example\result.zip" Dim extractPath As String = "c:\example\extract" ZipFile.CreateFromDirectory(startPath, zipPath) ZipFile.ExtractToDirectory(zipPath, extractPath) End Sub End Module
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.gif?cs-save-lang=1&cs-lang=vb)
.gif?cs-save-lang=1&cs-lang=vb)