Represents a package of compressed files in the zip archive format.
Assembly: System.IO.Compression (in System.IO.Compression.dll)
Initializes a new instance of theclass from the specified stream.
Initializes a new instance of theclass from the specified stream and with the specified mode.
|ZipArchive(Stream, ZipArchiveMode, Boolean)|
Initializes a new instance of theclass on the specified stream for the specified mode, and optionally leaves the stream open.
|ZipArchive(Stream, ZipArchiveMode, Boolean, Encoding)|
Initializes a new instance of theclass on the specified stream for the specified mode, uses the specified encoding for entry names, and optionally leaves the stream open.
Creates an empty entry that has the specified path and entry name in the zip archive.
Creates an empty entry that has the specified entry name and compression level in the zip archive.
Releases the resources used by the current instance of theclass.
Determines whether the specified object is equal to the current object.(Inherited from Object.)
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)
Retrieves a wrapper for the specified entry in the zip archive.
Serves as the default hash function. (Inherited from Object.)
Returns a string that represents the current object.(Inherited from Object.)
Overloaded. Archives a file by compressing it and adding it to the zip archive.(Defined by ZipFileExtensions.)
|CreateEntryFromFile(String, String, CompressionLevel)|
Overloaded. Archives a file by compressing it using the specified compression level and adding it to the zip archive.(Defined by ZipFileExtensions.)
Extracts all the files in the zip archive to a directory on the file system.(Defined by ZipFileExtensions.)
Create a zip archive from a directory
Extract the contents of a zip archive to a directory
Add new files to an existing zip archive
Retrieve a file from a zip archive
Retrieve all the files from a zip archive
Open a stream to a single file contained in a zip archive
Delete a file from a zip archive
When you create a new entry, the file is compressed and added to the zip package. The CreateEntry method enables you to specify a directory hierarchy when adding the entry. You include the relative path of the new entry within the zip package. For example, creating a new entry with a relative path of AddedFolder\NewFile.txt creates a compressed text file in a directory named AddedFolder.
If you reference the System.IO.Compression.FileSystem assembly in your project, you can access three extension methods (from the ZipFileExtensions class) for the class: CreateEntryFromFile, CreateEntryFromFile, and ExtractToDirectory. These extension methods enable you to compress and decompress the contents of the entry to a file. The System.IO.Compression.FileSystem assembly is not available for Windows 8.x Store apps. In Windows 8.x Store apps, you can compress and decompress files by using the DeflateStream or GZipStream class, or you can use the Windows Runtime types Compressor and Decompressor.
The first example shows how to create a new entry and write to it by using a stream.
The following example shows how to open a zip archive and iterate through the collection of entries.
The third example shows how to use extension methods to create a new entry in a zip archive from an existing file and extract the archive contents. You must reference the System.IO.Compression.FileSystem assembly to execute the code.
Available since 8
Available since 4.5
Portable Class Library
Supported in: portable .NET platforms
Available since 8.1
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.