Represents a compressed file within a zip archive.
Assembly: System.IO.Compression (in System.IO.Compression.dll)
Gets the zip archive that the entry belongs to.
Gets the compressed size of the entry in the zip archive.
Gets the relative path of the entry in the zip archive.
Gets or sets the last time the entry in the zip archive was changed.
Gets the uncompressed size of the entry in the zip archive.
Gets the file name of the entry in the zip archive.
Deletes the entry from the zip archive.
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.)
Serves as the default hash function. (Inherited from Object.)
Opens the entry from the zip archive.
Retrieves the relative path of the entry in the zip archive.(Overrides Object.ToString().)
Overloaded. Extracts an entry in the zip archive to a file.(Defined by ZipFileExtensions.)
Overloaded. Extracts an entry in the zip archive to a file, and optionally overwrites an existing file that has the same name.(Defined by ZipFileExtensions.)
A zip archive contains an entry for each compressed file. Theclass enables you to examine the properties of an entry, and open or delete the entry. When you open an entry, you can modify the compressed file by writing to the stream for that compressed file.
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 an file in a zip archive
Retrieve all of the files in a zip archive
To open a stream to an individual file contained in a zip archive
Delete a file from a zip archive
If you reference the System.IO.Compression.FileSystem assembly in your project, you can access two extension methods for the ExtractToFile(ZipArchiveEntry, String) and ExtractToFile(ZipArchiveEntry, String, Boolean), and they enable you to decompress the contents of the entry to a file. The System.IO.Compression.FileSystem assembly is not available in Windows 8. In Windows 8.x Store apps, you can decompress the contents of an archive by using DeflateStream or GZipStream, or you can use the Windows Runtime types Compressor and Decompressor to compress and decompress files.class. Those methods are
The first example shows how to create a new entry in a zip archive and write to it.
Imports System.IO Imports System.IO.Compression Module Module1 Sub Main() Using zipToOpen As FileStream = New FileStream("c:\users\exampleuser\release.zip", FileMode.Open) Using archive As ZipArchive = New ZipArchive(zipToOpen, ZipArchiveMode.Update) Dim readmeEntry As ZipArchiveEntry = archive.CreateEntry("Readme.txt") Using writer As StreamWriter = New StreamWriter(readmeEntry.Open()) writer.WriteLine("Information about this package.") writer.WriteLine("========================") End Using End Using End Using End Sub End Module
The second example shows how to use the ExtractToFile(ZipArchiveEntry, String) extension method. You must reference the System.IO.Compression.FileSystem assembly in your project for the code to execute.
Imports System.IO Imports System.IO.Compression Module Module1 Sub Main() Dim zipPath As String = "c:\example\start.zip" Dim extractPath As String = "c:\example\extract" Using archive As ZipArchive = ZipFile.OpenRead(zipPath) For Each entry As ZipArchiveEntry In archive.Entries If entry.FullName.EndsWith(".txt", StringComparison.OrdinalIgnoreCase) Then entry.ExtractToFile(Path.Combine(extractPath, entry.FullName)) End If Next End Using End Sub End Module
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.