Listing ZIP contents
suggest changeThis 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}");
}
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents