C# ZipArchive Entries
Description
ZipArchive Entries
Gets the collection of entries that
are currently in the zip archive.
Syntax
ZipArchive.Entries
has the following syntax.
public ReadOnlyCollection<ZipArchiveEntry> Entries { get; }
Example
The following example shows how to open a zip archive and iterate through the collection of entries.
/*from www . jav a 2 s.com*/
using System;
using System.IO;
using System.IO.Compression;
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));
}
}
}
}
}