ZipArchiveEntry.Name 속성

정의

zip 보관 파일에 있는 항목의 파일 이름을 가져옵니다.

public:
 property System::String ^ Name { System::String ^ get(); };
public string Name { get; }
member this.Name : string
Public ReadOnly Property Name As String

속성 값

zip 보관 파일에 있는 항목의 파일 이름입니다.

설명

속성은 Name 최종 디렉터리 구분 문자(\)를 따르는 속성 부분을 FullName 포함하며 하위 디렉터리 계층 구조는 포함하지 않습니다. 예를 들어 메서드를 사용하여 CreateEntryFromFile zip 보관 파일에 두 개의 항목을 만들고 첫 번째 항목의 NewEntry.txt 이름으로 제공하고 AddedFolder\\NewEntry.txt 두 번째 항목의 경우 두 항목이 모두 속성에 NewEntry.txt 포함 Name 됩니다. 첫 번째 항목도 NewEntry.txt 속성에 FullName 있지만 두 번째 항목은 속성에 AddedFolder\\NewEntry.txt 있습니다FullName. Windows 콜론(:)도 NTFS 규칙으로 인해 구분 기호로 처리되며, 이로 인해 Name 플랫폼 간에 다를 수 있습니다. 플랫폼 독립적 동작의 경우 항상 보관에 저장된 전체 항목 이름을 반영하는 기능을 사용할 FullName수 있습니다.

예제

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

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

적용 대상