Class LzipArchive

Class LzipArchive

名称: Aspose.Zip.Lzip 收藏: Aspose.Zip.dll (25.5.0)

此类代表一个 Lzip 档案文件. 使用它来编写或提取 L zip 文件。

public class LzipArchive : IArchive, IDisposable, IArchiveFileEntry

Inheritance

object LzipArchive

Implements

IArchive , IDisposable , IArchiveFileEntry

继承人

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

Constructors

LzipArchive(LzipArchiveSettings)

启动一个新的例子 Aspose.Zip.Lzip.LzipArchive。

public LzipArchive(LzipArchiveSettings settings = null)

Parameters

settings LzipArchiveSettings

设置特定 lzip 档案,定义词典大小。

LzipArchive(Stream)

启动一个新的例子 Aspose.Zip.Lzip.LzipArchive 类准备的压缩。

public LzipArchive(Stream sourceStream)

Parameters

sourceStream Stream

档案的来源。

Remarks

此构建器不解压. 查看 Aspose.Zip.Lzip.LzipArchive.Extract(System.IO.Stream) 解压方法。

Exceptions

ArgumentException

sourceStream’ is not seekable.

ArgumentNullException

sourceStream’ is null.

InvalidDataException

标题不符合 lzip 档案类型。

LzipArchive(线条)

启动一个新的例子 Aspose.Zip.Lzip.LzipArchive 类准备的压缩。

public LzipArchive(string path)

Parameters

path string

走到档案的源头。

Examples

using (FileStream extractedFile = File.Open(extractedFileName, FileMode.Create))
{
    using (var archive = new LzipArchive(sourceLzipFile))
    {
         archive.Extract(extractedFile);
       }
   }

Remarks

此构建器不解压. 查看 Aspose.Zip.Lzip.LzipArchive.Extract(System.IO.Stream) 解压方法。

Exceptions

ArgumentNullException

path’ is null.

SecurityException

召唤者没有所需的访问许可。

ArgumentException

path’ 是空的,只包含白色空间,或包含无效的字符。

UnauthorizedAccessException

拒绝访问 path" 文件。

PathTooLongException

指定的 path’, 文件名, 或两者都超过系统定义的最大长度. 例如,在基于 Windows 的平台上,路径必须小于 248 个字符, 文件名必须小于 260 个字符。

NotSupportedException

文件在 path’ 中间包含一个列(:)。

FileNotFoundException

文件未找到。

DirectoryNotFoundException

指定的路径是无效的,例如在无地图驱动器上。

IOException

文件已经开放了。

InvalidDataException

标题不符合 lzip 档案类型。

Properties

Settings

获取特定 lzip 档案的设置。

public LzipArchiveSettings Settings { get; }

财产价值

LzipArchiveSettings

Methods

Dispose()

执行与释放、释放或重新管理未管理资源相关的应用定义任务。

public void Dispose()

Dispose(博尔)

执行与释放、释放或重新管理未管理资源相关的应用定义任务。

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

管理的资源是否要消耗?

Extract(Stream)

将 lzip 存档提取到流。

public void Extract(Stream destination)

Parameters

destination Stream

存储压缩数据的流量。

Examples

using (FileStream sourceLzipFile = File.Open(sourceFileName, FileMode.Open))
{
   using (FileStream extractedFile = File.Open(extractedFileName, FileMode.Create))
   {
        using (var archive = new LzipArchive(sourceLzipFile))
        {
               archive.Extract(extractedFile);
        }
   }
}

Exceptions

InvalidOperationException

档案标题和服务信息未被阅读。

InvalidDataException

标题或支票中的数据错误。

ArgumentNullException

目的地流量为零。

ArgumentException

目的地流不支持写作。

Extract(FileInfo)

将 lzip 存档提取到文件中。

public void Extract(FileInfo fileInfo)

Parameters

fileInfo FileInfo

FileInfo 用于存储压缩数据。

Examples

using (FileStream lzipFile = File.Open(sourceFileName, FileMode.Open))
{
    using (var archive = new LzipArchive(lzipFile))
    {
        archive.Extract(new FileInfo("extracted.bin"));
    }
}

Exceptions

InvalidOperationException

档案标题和服务信息未被阅读。

SecurityException

呼叫者没有必要的许可,以打开 fileInfo。

ArgumentException

文件路径是空的,或者只包含白色空间。

FileNotFoundException

文件未找到。

UnauthorizedAccessException

到文件的路径是阅读或是一个目录。

ArgumentNullException

fileInfo’ is null.

DirectoryNotFoundException

指定的路径是无效的,例如在无地图驱动器上。

IOException

文件已经开放了。

Extract(线条)

通过路径将 lzip 档案提取到一个文件。

public void Extract(string path)

Parameters

path string

路径到文件,将存储压缩数据。

Examples

using (FileStream lzipFile = File.Open(sourceFileName, FileMode.Open))
{
    using (var archive = new LzipArchive(xzFile))
    {
        archive.Extract("extracted.bin");
    }
}

Exceptions

InvalidOperationException

档案标题和服务信息未被阅读。

ArgumentNullException

path’ is null.

SecurityException

召唤者没有所需的访问许可。

ArgumentException

path’ 是空的,只包含白色空间,或包含无效的字符。

UnauthorizedAccessException

拒绝访问 path" 文件。

PathTooLongException

指定的 path’, 文件名, 或两者都超过系统定义的最大长度. 例如,在基于 Windows 的平台上,路径必须小于 248 个字符, 文件名必须小于 260 个字符。

NotSupportedException

文件在 path’ 中间包含一个列(:)。

ExtractToDirectory(线条)

将档案内容提取到所提供的目录中。

public void ExtractToDirectory(string destinationDirectory)

Parameters

destinationDirectory string

路径到目录将提取的文件插入。

Remarks

如果目录不存在,它将被创建。

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- 网络名称不明。

Save(Stream)

将 lzip 存储到提供的流。

public void Save(Stream outputStream)

Parameters

outputStream Stream

目的地流

Examples

using (FileStream lzFile = File.Open("archive.lz", FileMode.Create))
{
    using (var archive = new LzipArchive())
    {
        archive.SetSource("data.bin");
        archive.Save(lzFile);
     }
}

Remarks

必须是可寻求的。

Exceptions

ArgumentException

outputStream’ does not support seeking.

ArgumentNullException

outputStream’ is null.

Save(线条)

存储 lzip 存档到提供的目的地文件。

public void Save(string destinationFileName)

Parameters

destinationFileName string

要创建档案的路径 如果指定的文件名指向现有文件,则将重写。

Examples

using (var archive = new LzipArchive()) 
{
    archive.SetSource(new FileInfo("data.bin"));
    archive.Save("result.lz");
}

Exceptions

ArgumentNullException

destinationFileName’ is null.

SecurityException

召唤者没有所需的访问许可。

ArgumentException

destinationFileName’ 是空的,只包含白色空间,或包含无效的字符。

UnauthorizedAccessException

拒绝访问 destinationFileName’ 文件。

PathTooLongException

指定的 destinationFileName’, 文件名, 或两者都超过系统定义的最大长度. 例如,在基于 Windows 的平台上,路径必须小于 248 个字符,文件名必须小于 260 个字符。

NotSupportedException

文件在 destinationFileName’ 包含字符串中间的一个列(:)。

Save(FileInfo)

存储 lzip 存档到提供的目的地文件。

public void Save(FileInfo destination)

Parameters

destination FileInfo

FileInfo,将作为目的地流开放。

Examples

using (var archive = new LzipArchive()) 
{
    archive.SetSource(new FileInfo("data.bin"));
    archive.Save(new FileInfo("archive.lz"));
}

Exceptions

SecurityException

呼叫者没有必要的许可,以打开 目的地。

ArgumentException

文件路径是空的,或者只包含白色空间。

FileNotFoundException

文件未找到。

UnauthorizedAccessException

到文件的路径是阅读或是一个目录。

ArgumentNullException

destination’ is null.

DirectoryNotFoundException

指定的路径是无效的,例如在无地图驱动器上。

IOException

文件已经开放了。

SetSource(Stream)

设置要压缩的内容在档案中。

public void SetSource(Stream source)

Parameters

source Stream

存档的输入流。

Examples

using (var archive = new LzipArchive())
   {
       archive.SetSource(new MemoryStream(new byte[] { 0x00, 0xFF }));
       archive.Save("archive.lz");
}

Exceptions

ArgumentException

源的流程是不可搜索的。

SetSource(FileInfo)

设置要压缩的内容在档案中。

public void SetSource(FileInfo fileInfo)

Parameters

fileInfo FileInfo

FileInfo 将作为输入流打开。

Examples

using (var archive = new LzipArchive()) 
{
    archive.SetSource(new FileInfo("data.bin"));
    archive.Save("archive.lz");
}

Exceptions

SecurityException

呼叫者没有必要的许可,以打开 fileInfo。

ArgumentException

文件路径是空的,或者只包含白色空间。

FileNotFoundException

文件未找到。

UnauthorizedAccessException

到文件的路径是阅读或是一个目录。

ArgumentNullException

fileInfo’ is null.

DirectoryNotFoundException

指定的路径是无效的,例如在无地图驱动器上。

IOException

文件已经开放了。

SetSource(线条)

设置要压缩的内容在档案中。

public void SetSource(string path)

Parameters

path string

文件要压缩的路径。

Examples

using (var archive = new LzipArchive()) 
{
    archive.SetSource("data.bin");
    archive.Save("archive.lz");
}

Exceptions

ArgumentNullException

path’ is null.

SecurityException

召唤者没有所需的访问许可。

ArgumentException

path’ 是空的,只包含白色空间,或包含无效的字符。

UnauthorizedAccessException

拒绝访问 path" 文件。

PathTooLongException

指定的 path’, 文件名, 或两者都超过系统定义的最大长度. 例如,在基于 Windows 的平台上,路径必须小于 248 个字符, 文件名必须小于 260 个字符。

NotSupportedException

文件在 path’ 中间包含一个列(:)。

 中文