Listing ZIP contents

suggest change

This snippet lists the entry names in a zip archive. The names are relative to the zip root. ZipArchive is in .NET Framework 4.5, in the System.IO.Compression assembly.

using (FileStream fs = new FileStream("archive.zip", FileMode.Open))
using (ZipArchive archive = new ZipArchive(fs, ZipArchiveMode.Read))
{
    for (int i = 0; i < archive.Entries.Count; i++)
    {
        Console.WriteLine($"{i}: {archive.Entries[i].FullName}");
    }
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents