ZipArchive.Entries Property
.NET Framework (current version)
Â
Namespace:
Â
System.IO.Compression
Assembly: Â System.IO.Compression (in System.IO.Compression.dll)
Return to top
![]() |
---|
The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience. |
Gets the collection of entries that are currently in the zip archive.
Assembly: Â System.IO.Compression (in System.IO.Compression.dll)
Property Value
Type: System.Collections.ObjectModel.ReadOnlyCollection<ZipArchiveEntry>The collection of entries that are currently in the zip archive.
Exception | Condition |
---|---|
NotSupportedException | The zip archive does not support reading. |
ObjectDisposedException | The zip archive has been disposed. |
InvalidDataException | The zip archive is corrupt, and its entries cannot be retrieved. |
Use the Entries property to retrieve the entire collection of entries. Use the GetEntry method to retrieve a single entry by name.
The following example shows how to open a zip archive and iterate through the collection of entries.
using System; using System.IO; using System.IO.Compression; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string zipPath = @"c:\example\start.zip"; string extractPath = @"c:\example\extract"; using (ZipArchive archive = ZipFile.OpenRead(zipPath)) { foreach (ZipArchiveEntry entry in archive.Entries) { if (entry.FullName.EndsWith(".txt", StringComparison.OrdinalIgnoreCase)) { entry.ExtractToFile(Path.Combine(extractPath, entry.FullName)); } } } } } }
Universal Windows Platform
Available since 8
.NET Framework
Available since 4.5
Portable Class Library
Supported in: portable .NET platforms
Windows Phone
Available since 8.1
Available since 8
.NET Framework
Available since 4.5
Portable Class Library
Supported in: portable .NET platforms
Windows Phone
Available since 8.1
Show: