C# ZipArchiveEntry Length

Description

ZipArchiveEntry Length Gets the uncompressed size of the entry in the zip archive.

Syntax

ZipArchiveEntry.Length has the following syntax.


public long Length { get; }

Example

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


using System;/*from ww  w.  jav  a  2  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