C# ZipArchiveEntry CompressedLength

Description

ZipArchiveEntry CompressedLength Gets the compressed size of the entry in the zip archive.

Syntax

ZipArchiveEntry.CompressedLength has the following syntax.


public long CompressedLength { get; }

Example


using System;//from  ww w.  j  a  v  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