ZipArchive.Entries Property


Gets the collection of entries that are currently in the zip archive.

public System.Collections.ObjectModel.ReadOnlyCollection<System.IO.Compression.ZipArchiveEntry> Entries { get; }
Property Value

The collection of entries that are currently in the zip archive.


The zip archive does not support reading.

The zip archive has been disposed.

The zip archive is corrupt, and its entries cannot be retrieved.


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\";
            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));
Imports System.IO
Imports System.IO.Compression

Module Module1

    Sub Main()
        Dim zipPath As String = "c:\example\"
        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
        End Using
    End Sub

End Module


Use the Entries property to retrieve the entire collection of entries. Use the GetEntry method to retrieve a single entry by name.

Applies to