C# ZipArchiveEntry Name

Description

ZipArchiveEntry Name Gets the file name of the entry in the zip archive.

Syntax

ZipArchiveEntry.Name has the following syntax.


public string Name { get; }

Example

The following example shows how to retrieve entries from a zip archive and evaluate the properties of the entries.


using System;//from   w w w. j ava2 s. c o  m
using System.IO;
using System.IO.Compression;
class Program
{
    static void Main(string[] args)
    {
        string zipPath = @"c:\example\result.zip";

        using (ZipArchive archive = ZipFile.OpenRead(zipPath))
        {
            foreach (ZipArchiveEntry entry in archive.Entries)
            {
                float compressedRatio = (float)entry.CompressedLength / entry.Length;
                float reductionPercentage = 100 - (compressedRatio * 100);

                Console.WriteLine (string.Format("File: {0}, Compressed {1:F2}%", entry.Name, reductionPercentage)); 
            }
        } 
    }
}




















Home »
  C# Tutorial »
    System.IO.Compression »




DeflateStream
GZipStream
ZipArchive
ZipArchiveEntry
ZipFile
ZipFileExtensions