Class ArchiveEntry

Class ArchiveEntry

Namespace: Aspose.Zip
Assembly: Aspose.Zip.dll (25.1.0)

아카이브 내의 단일 파일을 나타냅니다.

public abstract class ArchiveEntry : IArchiveFileEntry

상속

objectArchiveEntry

파생

ArchiveEntryEncrypted, ArchiveEntryPlain

구현

IArchiveFileEntry

상속된 멤버

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

비고

Aspose.Zip.ArchiveEntry 인스턴스를 Aspose.Zip.ArchiveEntryEncrypted로 캐스팅하여 항목이 암호화되었는지 여부를 확인합니다.

생성자

ArchiveEntry(string, CompressionSettings, Func<stream>, FileAttributes)

Aspose.Zip.ArchiveEntry 클래스의 새 인스턴스를 초기화합니다.

protected ArchiveEntry(string name, CompressionSettings compressionSettings, Func<stream> sourceProvider, FileAttributes fileAttributes)

매개변수

name string

항목 이름.

compressionSettings CompressionSettings

압축 또는 압축 해제를 위한 설정.

sourceProvider Func<Stream&gt;

압축할 항목 데이터가 포함된 스트림을 반환하는 메서드.

fileAttributes FileAttributes

파일 시스템에서의 속성.

ArchiveEntry(string, CompressionSettings, Stream, FileAttributes, FileSystemInfo)

Aspose.Zip.ArchiveEntry 클래스의 새 인스턴스를 초기화합니다.

protected ArchiveEntry(string name, CompressionSettings compressionSettings, Stream source, FileAttributes fileAttributes, FileSystemInfo fileInfo = null)

매개변수

name string

항목 이름.

compressionSettings CompressionSettings

압축 또는 압축 해제를 위한 설정.

source Stream

압축하거나 압축 해제할 항목 데이터가 포함된 스트림.

fileAttributes FileAttributes

파일 시스템에서의 속성.

fileInfo FileSystemInfo

항목 기반의 파일 또는 디렉터리 정보.

속성

Comment

아카이브 내의 항목 주석을 가져옵니다.

public string Comment { get; protected set; }

속성 값

string

CompressedSize

압축된 파일의 크기를 가져옵니다.

public ulong CompressedSize { get; }

속성 값

ulong

CompressionSettings

압축 또는 압축 해제를 위한 설정을 가져옵니다.

public CompressionSettings CompressionSettings { get; }

속성 값

CompressionSettings

DataSource

항목이 아카이브에 추가되었을 때의 소스입니다, 추출되지 않았습니다.

public Stream DataSource { get; }

속성 값

Stream

비고

할당되기 전에는 소스가 null입니다. 이 소스는 경우에 따라 Archive.Save 메서드 내에서 할당될 수 있습니다.

FileAttributes

호스트 시스템에서의 파일 속성을 가져옵니다.

protected FileAttributes FileAttributes { get; }

속성 값

FileAttributes

IsDirectory

항목이 디렉터리를 나타내는지 여부를 나타내는 값을 가져옵니다.

public bool IsDirectory { get; }

속성 값

bool

ModificationTime

마지막 수정 날짜 및 시간을 가져오거나 설정합니다.

public DateTime ModificationTime { get; set; }

속성 값

DateTime

Name

아카이브 내의 항목 이름을 가져옵니다.

public string Name { get; protected set; }

속성 값

string

UncompressedSize

원본 파일의 크기를 가져옵니다.

public ulong UncompressedSize { get; }

속성 값

ulong

메서드

Extract(string, string)

제공된 경로에 따라 파일 시스템으로 항목을 추출합니다.

public FileInfo Extract(string path, string password = null)

매개변수

path string

대상 파일의 경로. 파일이 이미 존재하면 덮어씌워집니다.

password string

선택적 비밀번호로, 암호 해제를 위한 것입니다.

반환

FileInfo

구성된 파일의 파일 정보.

예제

각각 고유한 비밀번호로 zip 아카이브의 두 항목을 추출합니다.

using (FileStream zipFile = File.Open("archive.zip", FileMode.Open))
{
    using (Archive archive = new Archive(zipFile))
    {
        archive.Entries[0].Extract("first.bin", "first_pass");
        archive.Entries[1].Extract("second.bin", "second_pass");
    }
}

예외

ArgumentNullException

path가 null입니다.

SecurityException

호출자가 액세스에 필요한 권한이 없습니다.

ArgumentException

path가 비어 있거나 공백만 포함하거나 유효하지 않은 문자가 포함되어 있습니다.

UnauthorizedAccessException

path에 대한 파일 접근이 거부되었습니다.

PathTooLongException

지정된 path, 파일 이름, 또는 둘 다 시스템에서 정의한 최대 길이를 초과합니다. 예를 들어, Windows 기반 플랫폼에서는 경로가 248자 미만이어야 하고, 파일 이름은 260자 미만이어야 합니다.

NotSupportedException

path에 문자열 중간에 콜론(:)이 포함되어 있습니다.

FileNotFoundException

파일을 찾을 수 없습니다.

DirectoryNotFoundException

지정된 경로가 유효하지 않으며, 예를 들어 매핑되지 않은 드라이브에 있을 수 있습니다.

IOException

파일이 이미 열려 있습니다.

InvalidDataException

데이터가 손상되었습니다. -또는- 항목에 대한 CRC 또는 MAC 검증이 실패했습니다.

Extract(Stream, string)

제공된 스트림으로 항목을 추출합니다.

public void Extract(Stream destination, string password = null)

매개변수

destination Stream

대상 스트림. 쓰기가 가능해야 합니다.

password string

선택적 비밀번호로, 암호 해제를 위한 것입니다.

예제

비밀번호로 zip 아카이브의 항목을 추출합니다.

using (FileStream zipFile = File.Open("archive.zip", FileMode.Open))
{
    using (Archive archive = new Archive(zipFile))
    {
        archive.Entries[0].Extract(httpResponseStream, "p@s$");
    }
}

예외

InvalidDataException

데이터가 손상되었습니다. -또는- 항목에 대한 CRC 또는 MAC 검증이 실패했습니다.

IOException

소스가 손상되었거나 읽을 수 없습니다.

ArgumentException

destination가 쓰기를 지원하지 않습니다.

Open(string)

추출을 위해 항목을 열고 압축 해제된 항목 내용이 있는 스트림을 제공합니다.

public Stream Open(string password = null)

매개변수

password string

선택적 비밀번호로, 암호 해제를 위한 것입니다.

반환

Stream

항목의 내용을 나타내는 스트림입니다.

예제

사용법: Stream decompressed = entry.Open();

.NET 4.0 이상 - Stream.CopyTo 메서드 사용: decompressed.CopyTo(httpResponse.OutputStream)

.NET 3.5 이하 - 바이트를 수동으로 복사:

byte[] buffer = new byte[8192];
int bytesRead;
while (0 &lt; (bytesRead = decompressed.Read(buffer, 0, buffer.Length)))
 fileStream.Write(buffer, 0, bytesRead);
```</p>

#### 비고

<p>스트림에서 읽어 파일의 원본 내용을 가져옵니다. 예제 섹션을 참조하십시오.</p>

#### 예외

 [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception)

아카이브의 상태가 올바르지 않습니다.

### <a id="Aspose_Zip_ArchiveEntry_CompressionProgressed"></a> CompressionProgressed

원시 스트림의 일부가 압축될  발생합니다.

```csharp
public event EventHandler<progresseventargs> CompressionProgressed

이벤트 유형

EventHandler<ProgressEventArgs&gt;

예제

archive.Entries[0].CompressionProgressed += (s, e) =&gt; { int percent = (int)((100 * (long)e.ProceededBytes) / entrySourceStream.Length); };

비고

이벤트 발신자는 Aspose.Zip.ArchiveEntry 인스턴스입니다.

ExtractionProgressed

원시 스트림의 일부가 추출될 때 발생합니다.

public event EventHandler<progresseventargs> ExtractionProgressed

이벤트 유형

EventHandler<ProgressEventArgs&gt;

예제

archive.Entries[0].ExtractionProgressed += (s, e) =&gt; { int percent = (int)((100 * e.ProceededBytes) / ((ArchiveEntry)s).UncompressedSize); };

비고

이벤트 발신자는 Aspose.Zip.ArchiveEntry 인스턴스입니다.

 한국어