Class SevenZipArchive

Class SevenZipArchive

이름 공간 : Aspose.Zip.SevenZip 모임: Aspose.Zip.dll (25.5.0)

이 클래스는 7z 아카이브 파일을 나타냅니다. 7z 아카이브를 구성하고 추출하는 데 사용하십시오.

public class SevenZipArchive : IArchive, IDisposable

Inheritance

object SevenZipArchive

Implements

IArchive , IDisposable

상속 회원들

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

Constructors

SevenZipArchive(SevenZipEntrySettings)

Aspose.Zip.SevenZip.SevenZipArchive 클래스의 새로운 예를 시작하여 입력에 대한 선택적 설정이 있습니다.

public SevenZipArchive(SevenZipEntrySettings newEntrySettings = null)

Parameters

newEntrySettings SevenZipEntrySettings

새로 추가 된 Aspose.Zip.SevenZip.SevenZipArchiveEntry 항목에 사용되는 압축 및 암호화 설정.지정되지 않으면 암호화없이 LZMA 압축이 사용됩니다.

Examples

다음 예제는 기본 설정을 사용하여 단일 파일을 압축하는 방법을 보여줍니다 : 암호화없이 LZMA 인쇄.

using (FileStream sevenZipFile = File.Open("archive.7z", FileMode.Create))
{
    using (var archive = new SevenZipArchive())
    {
        archive.CreateEntry("data.bin", "file.dat");
        archive.Save(sevenZipFile);
    }
}

SevenZipArchive(스트리밍, 스트리밍)

Aspose.Zip.SevenZip.SevenZipArchive 클래스의 새로운 예를 시작하고 아카이브에서 추출 할 수있는 입력 목록을 구성합니다.

public SevenZipArchive(Stream sourceStream, string password = null)

Parameters

sourceStream Stream

아카이브의 출처입니다.

password string

암호화에 대한 선택적 암호. 파일 이름이 암호화되면, 그것은 존재해야합니다.

Examples

using (SevenZipArchive archive = new SevenZipArchive(File.OpenRead("archive.7z")))
{
    archive.ExtractToDirectory("C:\\extracted");
}

Remarks

이 건축기는 어떤 입력도 압축하지 않습니다. Aspose.Zip.SevenZip.SevenZipArchive.ExtractToDirectory(System.String,System.String) 압축 방법을 참조하십시오.

Exceptions

ArgumentException

sourceStream’ is not seekable.

ArgumentNullException

sourceStream’ is null.

NotImplementedException

아카이브에는 하나 이상의 코더가 포함되어 있습니다.이제 LZMA 압축만 지원됩니다.

SevenZipArchive(스트링, 스트링)

Aspose.Zip.SevenZip.SevenZipArchive 클래스의 새로운 예를 시작하고 아카이브에서 추출 할 수있는 입력 목록을 구성합니다.

public SevenZipArchive(string path, string password = null)

Parameters

path string

완전히 자격을 갖춘 또는 아카이브 파일에 대한 상대 경로.

password string

암호화에 대한 선택적 암호. 파일 이름이 암호화되면, 그것은 존재해야합니다.

Examples

using (SevenZipArchive archive = new SevenZipArchive("archive.7z"))
{
    archive.ExtractToDirectory("C:\\extracted");
}

Remarks

이 건축기는 어떤 입력도 압축하지 않습니다. Aspose.Zip.SevenZip.SevenZipArchive.ExtractToDirectory(System.String,System.String) 압축 방법을 참조하십시오.

Exceptions

ArgumentNullException

path’ is null.

SecurityException

호출자는 필요한 액세스 허가를 가지고 있지 않습니다.

ArgumentException

path’는 텅 비어 있고, 흰색 공간만 포함하거나, 불가능한 문자를 포함합니다.

UnauthorizedAccessException

path" 파일에 대한 액세스는 거부됩니다.

PathTooLongException

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

NotSupportedException

path’에 있는 파일에는 링의 중간에 있는 열(:)이 포함되어 있습니다.

FileNotFoundException

파일은 찾을 수 없습니다.

DirectoryNotFoundException

지정된 경로는 불가능하며, 예를 들어 지정되지 않은 드라이브에 있습니다.

IOException

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

SevenZipArchive(스트리트[ ] [ [ ], 링크)

Aspose.Zip.SevenZip.SevenZipArchive 클래스를 멀티 볼륨 7z 아카이브에서 시작하고 아카이브에서 추출 할 수있는 입력 목록을 구성합니다.

public SevenZipArchive(string[] parts, string password = null)

Parameters

parts string [ ] [ [ ]

주문을 준수하는 멀티 볼륨 7z 아카이브의 각 세그먼트로의 경로

password string

암호화에 대한 선택적 암호. 파일 이름이 암호화되면, 그것은 존재해야합니다.

Examples

using (SevenZipArchive archive = new SevenZipArchive(new string[] { "multi.7z.001", "multi.7z.002", "multi.7z.003" }))
{
    archive.ExtractToDirectory("C:\\extracted");
}

Exceptions

ArgumentNullException

parts’ is null.

ArgumentException

parts’ has no entries.

SecurityException

호출자는 필요한 액세스 허가를 가지고 있지 않습니다.

ArgumentException

파일로 가는 경로는 텅 비어 있고, 단지 흰색 공간만 포함되어 있거나, 부적절한 문자를 포함합니다.

UnauthorizedAccessException

파일에 대한 액세스는 거부됩니다.

PathTooLongException

예를 들어 Windows 기반 플랫폼에서는 경로가 248자 미만이어야 하며 파일 이름은 260자 미만이어야 합니다.

NotSupportedException

경로에 있는 파일에는 끈의 중간에 있는 열(:)이 포함되어 있습니다.

Properties

Entries

아카이브를 구성하는 Aspose.Zip.SevenZip.SevenZipArchiveEntry 형식의 입력을 얻습니다.

public ReadOnlyCollection<sevenziparchiveentry> Entries { get; }

부동산 가치

ReadOnlyCollection &lt에 대한 정보 SevenZipArchiveEntry >

NewEntrySettings

새로 추가 된 Aspose.Zip.SevenZip.SevenZipArchiveEntry 항목에 사용되는 압축 및 암호화 설정.

public SevenZipEntrySettings NewEntrySettings { get; }

부동산 가치

SevenZipEntrySettings

Methods

CreateEntries(디렉토리Info, Bool)

아카이브에 모든 파일과 디렉토리를 주어진 디렉토리에 반복적으로 추가합니다.

public SevenZipArchive CreateEntries(DirectoryInfo directory, bool includeRootDirectory = true)

Parameters

directory DirectoryInfo

컴프레스를 위한 디렉토리

includeRootDirectory bool

뿌리 디렉토리 자체를 포함하거나 포함하지 않는지 나타냅니다.

Returns

SevenZipArchive

아카이브는 작성된 포스팅으로 구성되어 있습니다.

Examples

using (SevenZipArchive archive = new SevenZipArchive())
{
    DirectoryInfo folder = new DirectoryInfo("C:\folder");
    archive.CreateEntries(folder);
    archive.Save("folder.7z");
}

Exceptions

DirectoryNotFoundException

directory’로 가는 경로는 불가능하며, 예를 들어 맵화되지 않은 드라이브에 있습니다.

SecurityException

호출자는 directory"에 액세스 할 수있는 필요한 허가를 가지고 있지 않습니다.

CreateEntries(링크, 볼)

아카이브에 모든 파일과 디렉토리를 주어진 디렉토리에 반복적으로 추가합니다.

public SevenZipArchive CreateEntries(string sourceDirectory, bool includeRootDirectory = true)

Parameters

sourceDirectory string

컴프레스를 위한 디렉토리

includeRootDirectory bool

뿌리 디렉토리 자체를 포함하거나 포함하지 않는지 나타냅니다.

Returns

SevenZipArchive

아카이브는 작성된 포스팅으로 구성되어 있습니다.

Examples

LZMA2 압축을 사용하여 7z 아카이브를 구성합니다.

using (SevenZipArchive archive = new SevenZipArchive(new SevenZipEntrySettings(new SevenZipLZMACompressionSettings())))
{
    archive.CreateEntries("C:\folder");
    archive.Save("folder.7z");
}

CreateEntry(링크, FileInfo, bool, SevenZipEntrySettings)

아카이브 내에서 단일 입력을 만듭니다.

public SevenZipArchiveEntry CreateEntry(string name, FileInfo fileInfo, bool openImmediately = false, SevenZipEntrySettings newEntrySettings = null)

Parameters

name string

입구의 이름입니다.

fileInfo FileInfo

파일의 메타 데이터가 압축됩니다.

openImmediately bool

사실, 즉시 파일을 열면, 그렇지 않으면 파일을 저장할 수 있습니다.

newEntrySettings SevenZipEntrySettings

압축 및 암호화 설정은 Aspose.Zip.SevenZip.SevenZipArchiveEntry 항목을 추가하는 데 사용됩니다.

Returns

SevenZipArchiveEntry

일곱 개의 ZIP 입구.

Examples

각각 다른 암호로 암호화 된 입력과 함께 아카이브를 구성합니다.

using (FileStream sevenZipFile = File.Open("archive.7z", FileMode.Create))
{
    FileInfo fi1 = new FileInfo("data1.bin");
    FileInfo fi2 = new FileInfo("data2.bin");
    FileInfo fi3 = new FileInfo("data3.bin");
    using (var archive = new SevenZipArchive())
    {
        archive.CreateEntry("entry1.bin", fi1, false, new SevenZipEntrySettings(new SevenZipStoreCompressionSettings(), new SevenZipAESEncryptionSettings("test1")));
        archive.CreateEntry("entry2.bin", fi2, false, new SevenZipEntrySettings(new SevenZipStoreCompressionSettings(), new SevenZipAESEncryptionSettings("test2")));
        archive.CreateEntry("entry3.bin", fi3, false, new SevenZipEntrySettings(new SevenZipStoreCompressionSettings(), new SevenZipAESEncryptionSettings("test3")));
        archive.Save(sevenZipFile);
    }
}

Remarks

입력 이름은 단지 파라미터 내에 설정됩니다.파라미터에 제공된 파일 이름은 입력 이름에 영향을 미치지 않습니다.

파일이 파라미터로 즉시 열리면 파일이 저장될 때까지 차단됩니다.

Exceptions

UnauthorizedAccessException

fileInfo’ is read-only or is a directory.

DirectoryNotFoundException

지정된 경로는 불가능하며, 예를 들어 지정되지 않은 드라이브에 있습니다.

IOException

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

CreateEntry(스트림, 스트림, SevenZipEntrySettings, FileSystemInfo)

아카이브 내에서 단일 입력을 만듭니다.

public SevenZipArchiveEntry CreateEntry(string name, Stream source, SevenZipEntrySettings newEntrySettings, FileSystemInfo fileInfo)

Parameters

name string

입구의 이름입니다.

source Stream

입구에 대한 입력 스트림.

newEntrySettings SevenZipEntrySettings

압축 및 암호화 설정은 Aspose.Zip.SevenZip.SevenZipArchiveEntry 항목을 추가하는 데 사용됩니다.

fileInfo FileSystemInfo

파일 또는 폴더의 메타 데이터가 압축됩니다.

Returns

SevenZipArchiveEntry

7Zip 입구

Examples

LZMA2 압축 암호화 된 입력과 함께 아카이브를 구성합니다.

using (FileStream sevenZipFile = File.Open("archive.7z", FileMode.Create))
{
    using (var archive = new SevenZipArchive())
    {
        archive.CreateEntry("entry1.bin", new MemoryStream(new byte[] {0x00, 0xFF}), new SevenZipEntrySettings(new SevenZipLZMA2CompressionSettings(), new SevenZipAESEncryptionSettings("test1")), new FileInfo("data1.bin")); 
        archive.Save(sevenZipFile);
    }
}

Remarks

입력 이름은 단지 파라미터 내에 설정됩니다.파라미터에 제공된 파일 이름은 입력 이름에 영향을 미치지 않습니다.

이 게시물을 즐겨찾기로 설정 6월 19 can refer to System.IO.DirectoryInfo if the entry is directory.

Exceptions

InvalidOperationException

source’와 fileInfo’는 null 또는 source’는 null이며 fileInfo’는 디렉토리에 해당합니다.

CreateEntry(스트림, 스트림, SevenZipEntrySettings)

아카이브 내에서 단일 입력을 만듭니다.

public SevenZipArchiveEntry CreateEntry(string name, Stream source, SevenZipEntrySettings newEntrySettings = null)

Parameters

name string

입구의 이름입니다.

source Stream

입구에 대한 입력 스트림.

newEntrySettings SevenZipEntrySettings

압축 및 암호화 설정은 Aspose.Zip.SevenZip.SevenZipArchiveEntry 항목을 추가하는 데 사용됩니다.

Returns

SevenZipArchiveEntry

ZIP 입구

Examples

LZMA2 압축 및 모든 입력 암호화와 함께 7z 아카이브를 구성합니다.

using (var archive = new SevenZipArchive(new SevenZipEntrySettings(new SevenZipLZMA2CompressionSettings(), new SevenZipAESEncryptionSettings("p@s$"))))
{
    archive.CreateEntry("data.bin", new MemoryStream(new byte[] {0x00, 0xFF} ));
    archive.Save("archive.7z");
}

CreateEntry(스트리트, 스트리트, Bool, SevenZipEntrySettings)

아카이브 내에서 단일 입력을 만듭니다.

public SevenZipArchiveEntry CreateEntry(string name, string path, bool openImmediately = false, SevenZipEntrySettings newEntrySettings = null)

Parameters

name string

입구의 이름입니다.

path string

새 파일의 완전히 자격을 갖춘 이름, 또는 압축 될 상대 파일 이름.

openImmediately bool

사실, 즉시 파일을 열면, 그렇지 않으면 파일을 저장할 수 있습니다.

newEntrySettings SevenZipEntrySettings

압축 및 암호화 설정은 Aspose.Zip.SevenZip.SevenZipArchiveEntry 항목을 추가하는 데 사용됩니다.

Returns

SevenZipArchiveEntry

ZIP 입구

Examples

using (FileStream sevenZipFile = File.Open("archive.7z", FileMode.Create))
{
    using (var archive = new SevenZipArchive(new SevenZipEntrySettings(new SevenZipLZMA2CompressionSettings())))
    {
        archive.CreateEntry("data.bin", "file.dat");
        archive.Save(sevenZipFile);
    }
}

Remarks

입력 이름은 단지 파라미터 내에 설정됩니다.파라미터에 제공된 파일 이름은 입력 이름에 영향을 미치지 않습니다.

파일이 파라미터로 즉시 열리면 파일이 저장될 때까지 차단됩니다.

Exceptions

ArgumentNullException

path’ is null.

SecurityException

호출자는 필요한 액세스 허가를 가지고 있지 않습니다.

ArgumentException

path’는 텅 비어 있고, 흰색 공간만 포함하거나, 불가능한 문자를 포함합니다.

UnauthorizedAccessException

path" 파일에 대한 액세스는 거부됩니다.

PathTooLongException

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

NotSupportedException

path’에 있는 파일에는 링의 중간에 있는 열(:)이 포함되어 있습니다.

Dispose()

응용 프로그램으로 정의된 작업을 수행하며, 관리되지 않은 자원을 배출, 배출 또는 재배치하는 것과 관련이 있습니다.

public void Dispose()

Dispose(바울)

응용 프로그램으로 정의된 작업을 수행하며, 관리되지 않은 자원을 배출, 배출 또는 재배치하는 것과 관련이 있습니다.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

관리된 자원이 낭비되어야 한다.

ExtractToDirectory(스트링, 스트링)

아카이브에 있는 모든 파일을 제공된 디렉토리로 추출합니다.

public void ExtractToDirectory(string destinationDirectory, string password = null)

Parameters

destinationDirectory string

디렉토리로 이동하여 추출된 파일을 입력합니다.

password string

콘텐츠 암호화에 대한 선택적 암호.

Examples

using (var archive = new SevenZipArchive("archive.7z")) 
{ 
   archive.ExtractToDirectory("C:\extracted");
}

Remarks

디렉토리가 존재하지 않는다면, 그것은 만들어집니다.

파일 이름이 암호화되면 Aspose.Zip.SevenZapArchive.#ctor(System.String,Systems. String) 또는 __ WL51.Zib.seven ZipArkive.(Sistem.Io.Stream,system.string )에서 비밀번호를 제공합니다.

Exceptions

ArgumentNullException

destinationDirectory’ is null.

PathTooLongException

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

SecurityException

호출자는 기존 디렉토리에 액세스 할 수있는 필요한 허가를 가지고 있지 않습니다.

NotSupportedException

디렉토리가 존재하지 않는 경우, 경로는 드라이브 라벨의 일부가 아닌 척추 캐릭터 (:)를 포함합니다 (“C:”).

ArgumentException

destinationDirectory’ is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the System.IO.Path.GetInvalidPathChars method. -or- path is prefixed with, or contains, only a colon character (:).

IOException

경로에 의해 지정된 디렉토리는 파일입니다. -or- 네트워크 이름은 알려지지 않습니다.

InvalidDataException

아카이브가 부패했다.

Save(Stream)

제공되는 스트림에 7z 아카이브를 저장합니다.

public void Save(Stream output)

Parameters

output Stream

목적지 흐름

Examples

using (FileStream sevenZipFile = File.Open("archive.7z", FileMode.Create))
{
  using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
  {
    using (var archive = new SevenZipArchive())
    {
      archive.CreateEntry("data", source);
      archive.Save(sevenZipFile);
    }
  }
}

Remarks

찾을 수 있어야 합니다.

Exceptions

ArgumentException

output’ does not support seeking.

ArgumentNullException

output’ is null.

InvalidOperationException

암호는 데이터를 압축하지 못했습니다.

Save(스트리트)

제공된 목적지 파일에 아카이브를 저장합니다.

public void Save(string destinationFileName)

Parameters

destinationFileName string

만약 지정된 파일 이름이 기존 파일을 지정한다면, 그것은 과장됩니다.

Examples

using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
{
   using (var archive = new SevenZipArchive(new SevenZipEntrySettings(new SevenZipLZMACompressionSettings())))
   {
      archive.CreateEntry("data", source);
      archive.Save("archive.7z");
   }
}

Remarks

아카이브를 동일한 경로로 저장할 수 있습니다.그러나 이 접근 방식은 일시적인 파일로 복사하는 것을 사용하기 때문에 이것은 권장되지 않습니다.

Exceptions

ArgumentNullException

destinationFileName’ is null.

SecurityException

호출자는 필요한 액세스 허가를 가지고 있지 않습니다.

ArgumentException

destinationFileName’는 텅 비어 있고, 단지 흰색 공간만 포함되어 있거나, 부적절한 문자를 포함합니다.

UnauthorizedAccessException

destinationFileName’ 파일에 대한 액세스는 거부됩니다.

PathTooLongException

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

NotSupportedException

destinationFileName’에 있는 파일에는 라인의 중간에 있는 열(:)이 포함되어 있습니다.

SaveSplit(스트리트, SplitSevenZipArchiveSaveOptions)

제공된 목적지 디렉토리로 멀티 볼륨 아카이브를 저장합니다.

public void SaveSplit(string destinationDirectory, SplitSevenZipArchiveSaveOptions options)

Parameters

destinationDirectory string

아카이브 세그먼트가 생성되는 디렉토리로 가는 경로.

options SplitSevenZipArchiveSaveOptions

파일 이름을 포함하여 파일 저장 옵션.

Examples

using (SevenZipArchive archive = new SevenZipArchive())
{
    archive.CreateEntry("entry.bin", "data.bin");
    archive.SaveSplit(@"C:\Folder",  new SplitSevenZipArchiveSaveOptions("volume", 65536));
}

Remarks

이 방법은 여러 () 파일을 filename.7z.001, filename.7z.002, …, filename.7z.(n)로 구성합니다.

기존 아카이브를 다량 볼륨으로 만들 수 없습니다.

Exceptions

InvalidOperationException

이 아카이브는 기존 출처에서 열렸습니다.

ArgumentNullException

destinationDirectory’ is null.

SecurityException

호출자는 디렉토리에 액세스 할 수있는 필요한 허가를 가지고 있지 않습니다.

ArgumentException

destinationDirectory’ contains invalid characters such as “, >, <, or |.

PathTooLongException

지정된 경로는 시스템에 의해 정의된 최대 길이를 초과합니다.

 한국어