Share via


ZipArchiveEntry.CompressedLength 속성

정의

zip 보관 위치에 있는 항목의 압축된 크기를 가져옵니다.

public:
 property long CompressedLength { long get(); };
public long CompressedLength { get; }
member this.CompressedLength : int64
Public ReadOnly Property CompressedLength As Long

속성 값

zip 보관 위치에 있는 항목의 압축된 크기입니다.

예외

항목이 수정되어 속성 값을 사용할 수 없는 경우

예제

다음 예제에서는 zip 보관에서 항목을 검색하고 항목의 속성을 평가하는 방법을 보여줍니다. 속성을 사용하여 항목의 이름을 표시하고 LengthCompressedLength 속성을 사용하여 Name 파일이 압축된 양을 계산합니다.

using System;
using System.IO;
using System.IO.Compression;

namespace ConsoleApplication1
{
    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));
                }
            }
        }
    }
}
Imports System.IO
Imports System.IO.Compression

Module Module1

    Sub Main()
        Dim zipPath As String = "c:\example\result.zip"

        Using archive As ZipArchive = ZipFile.OpenRead(zipPath)
            For Each entry As ZipArchiveEntry In archive.Entries
                Dim compressedRatio As Single = entry.CompressedLength / entry.Length
                Dim reductionPercentage As Single = 100 - (compressedRatio * 100)

                Console.WriteLine(String.Format("File: {0}, Compressed {1:F2}%", entry.Name, reductionPercentage))
            Next
        End Using
    End Sub

End Module

설명

모드가 로 설정되거나 모드가 로 설정 Create되고 항목이 열린 경우 이 속성을 검색할 Update 수 없습니다.

적용 대상