Class TarArchive

Class TarArchive

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

此类代表一个tar档案文件. 使用它来编写、提取或更新tar文件。

public class TarArchive : IArchive, IDisposable

Inheritance

object TarArchive

Implements

IArchive , IDisposable

继承人

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

Constructors

TarArchive()

启动了 Aspose.Zip.Tar.TarArchive 类的新例子。

public TarArchive()

Examples

下面的例子表明如何压缩文件。

using (var archive = new TarArchive())
{
    archive.CreateEntry("first.bin", "data.bin");
    archive.Save("archive.tar");
}

TarArchive(Stream)

启动 Aspose.Zip.Archive 类的新例子,并组成可以从档案中提取的输入列表。

public TarArchive(Stream sourceStream)

Parameters

sourceStream Stream

資料來源:必須可搜尋。

Examples

下面的示例显示如何将所有输入提取到一个目录。

using (var archive = new TarArchive(File.OpenRead("archive.tar")))
{ 
   archive.ExtractToDirectory("C:\extracted");
}

Remarks

此制造商不会解包任何输入. 查看 Aspose.Zip.Tar.TarEntry.Open 解包方法。

Exceptions

ArgumentException

sourceStream’ is not seekable.

ArgumentNullException

sourceStream’ is null.

TarArchive(线条)

启动 Aspose.Zip.Tar.tarArchive 类的新例子,并组成可以从档案中提取的输入列表。

public TarArchive(string path)

Parameters

path string

走向档案的路径。

Examples

下面的示例显示如何将所有输入提取到一个目录。

using (var archive = new TarArchive("archive.tar")) 
{ 
   archive.ExtractToDirectory("C:\extracted");
}

Remarks

此制造商不会解包任何输入. 查看 Aspose.Zip.Tar.TarEntry.Open 解包方法。

Exceptions

ArgumentNullException

path’ is null.

SecurityException

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

ArgumentException

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

UnauthorizedAccessException

拒绝访问 path" 文件。

PathTooLongException

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

NotSupportedException

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

FileNotFoundException

文件未找到。

DirectoryNotFoundException

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

IOException

文件已经开放了。

Properties

Entries

收到 Aspose.Zip.Tar.TarEntry 类型的输入,构成档案。

public ReadOnlyCollection<tarentry> Entries { get; }

财产价值

ReadOnlyCollection < TarEntry >

Methods

CreateEntries(首页 > 博尔)

将所有文件和目录重复添加到存档中。

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

Parameters

directory DirectoryInfo

编辑器压缩。

includeRootDirectory bool

指示是否要包含根目录本身。

Returns

TarArchive

编写的存档与输入。

Examples

using (FileStream tarFile = File.Open("archive.tar", FileMode.Create))
{
    using (var archive = new TarArchive())
    {
        archive.CreateEntries(new DirectoryInfo("C:\folder"), false);
        archive.Save(tarFile);
    }
}

CreateEntries(布尔,布尔)

将所有文件和目录重复添加到存档中。

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

Parameters

sourceDirectory string

编辑器压缩。

includeRootDirectory bool

指示是否要包含根目录本身。

Returns

TarArchive

编写的存档与输入。

Examples

using (FileStream tarFile = File.Open("archive.tar", FileMode.Create))
{
    using (var archive = new TarArchive())
    {
        archive.CreateEntries("C:\folder", false);
        archive.Save(tarFile);
    }
}

Exceptions

ArgumentNullException

sourceDirectory’ is null.

SecurityException

通话者没有必要的许可访问 sourceDirectory。

ArgumentException

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

PathTooLongException

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

CreateEntry(字符串, 流, FileSystemInfo)

在档案中创建一个单一输入。

public TarEntry CreateEntry(string name, Stream source, FileSystemInfo fileInfo = null)

Parameters

name string

入口的名称。

source Stream

输入流的输入流。

fileInfo FileSystemInfo

要压缩的文件或文件夹的代码。

Returns

TarEntry

入口案例。

Examples

using (var archive = new TarArchive())
{
   archive.CreateEntry("bytes", new MemoryStream(new byte[] {0x00, 0xFF}));
   archive.Save(tarFile);
}

Remarks

输入名单仅在参数中设置,参数中提供的文件名不影响输入名单。

可以提到 System.IO.DirectoryInfo 如果输入是目录。

Exceptions

PathTooLongException

name’ is too long for tar as of IEEE 1003.1-1998 standard.

ArgumentException

文件名,作为 name 的一部分,超过 100 个符号。

CreateEntry(字符串,FileInfo,bool)

在档案中创建一个单一输入。

public TarEntry CreateEntry(string name, FileInfo fileInfo, bool openImmediately = false)

Parameters

name string

入口的名称。

fileInfo FileInfo

要压缩的文件或文件夹的代码。

openImmediately bool

事实上,如果立即打开文件,否则在存储档案上打开文件。

Returns

TarEntry

入口案例。

Examples

FileInfo fi = new FileInfo("data.bin");
using (var archive = new TarArchive())
{
   archive.CreateEntry("data.bin", fi);
   archive.Save(tarFile);
}

Remarks

输入名单仅在参数中设置,参数中提供的文件名不影响输入名单。

可以提到 System.IO.DirectoryInfo 如果输入是目录。

如果文件与参数立即打开,它将被阻止,直到档案被删除。

Exceptions

PathTooLongException

name’ is too long for tar as of IEEE 1003.1-1998 standard.

ArgumentException

文件名,作为 name 的一部分,超过 100 个符号。

CreateEntry(字符串,字符串,bool)

在档案中创建一个单一输入。

public TarEntry CreateEntry(string name, string path, bool openImmediately = false)

Parameters

name string

入口的名称。

path string

文件要压缩的路径。

openImmediately bool

事实上,如果立即打开文件,否则在存储档案上打开文件。

Returns

TarEntry

入口案例。

Examples

using (var archive = new TarArchive())
{
    archive.CreateEntry("first.bin", "data.bin");
    archive.Save(outputTarFile);
}

Remarks

输入名单仅在参数中设置,参数中提供的文件名不影响输入名单。

如果文件与参数立即打开,它将被阻止,直到档案被删除。

Exceptions

ArgumentNullException

path’ is null.

SecurityException

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

ArgumentException

path’ 是空的,只包含白色空间,或包含无效的字符 - 或 - 文件名,作为 name’ 的部分,超过 100 个符号。

UnauthorizedAccessException

拒绝访问 path” 文件。

PathTooLongException

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

NotSupportedException

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

DeleteEntry(TarEntry)

从输入列表中删除特定输入的第一次出现。

public TarArchive DeleteEntry(TarEntry entry)

Parameters

entry TarEntry

输入要从输入列表中删除。

Returns

TarArchive

包含输入的档案已删除。

Examples

下面是如何删除所有输入,除了最后一个:

using (var archive = new TarArchive("archive.tar"))
{
    while (archive.Entries.Count &gt; 1)
        archive.DeleteEntry(archive.Entries[0]);
    archive.Save(outputTarFile);
}

DeleteEntry(因特)

按指数从输入列表中删除输入。

public TarArchive DeleteEntry(int entryIndex)

Parameters

entryIndex int

以零为基础的输入指数要删除。

Returns

TarArchive

包含输入的档案已删除。

Examples

using (var archive = new TarArchive("two_files.tar"))
{
    archive.DeleteEntry(0);
    archive.Save("single_file.tar");
}

Exceptions

ArgumentOutOfRangeException

entryIndex’ is less than 0.-or- entryIndex’ is equal to or greater than ‘Entries’ count.

Dispose()

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

public void Dispose()

Dispose(博尔)

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

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

管理的资源是否要消耗?

ExtractToDirectory(线条)

将存档中的所有文件提取到所提供的目录中。

public void ExtractToDirectory(string destinationDirectory)

Parameters

destinationDirectory string

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

Examples

Using (var archive = new TarArchive("archive.tar")) 
{ 
   archive.ExtractToDirectory("C:\extracted");
}

Remarks

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

Exceptions

ArgumentNullException

路是零

PathTooLongException

例如,在基于 Windows 的平台上,路径必须小于 248 个字符,文件名必须小于 260 个字符。

SecurityException

呼叫者没有必要的许可访问现有目录。

NotSupportedException

如果目录不存在,路径包含一个列符(:)不属于驱动标签(“C:”)的一部分。

ArgumentException

路径是零长的线条,仅包含白空间,或包含一个或多个无效的字符. 您可以通过使用 System.IO.Path.GetInvalid PathChars 方法查询不合格的文字符。

IOException

路径指定的目录是一个文件 - 或 - 不知名的网络名称。

来自GZIP(Stream)

提取的 gzip 档案和组成 Aspose.Zip.Tar.TarArchive 从提取的数据。

重要: gzip 存档是完全提取在这个方法,其内容是内部保存。

public static TarArchive FromGZip(Stream source)

Parameters

source Stream

档案的来源。

Returns

TarArchive

此分類上一篇: Aspose.Zip.Tar.TarArchive

Remarks

GZip提取流因压缩算法的性质而不可寻找。Tar 存档提供了随意提取记录的方便,因此它必须在洞下运行可搜索的流。

Exceptions

InvalidDataException

档案被腐败了。

来自GZIP(线条)

提取的 gzip 档案和组成 Aspose.Zip.Tar.TarArchive 从提取的数据。

重要: gzip 存档是完全提取在这个方法,其内容是内部保存。

public static TarArchive FromGZip(string path)

Parameters

path string

走向档案的路径。

Returns

TarArchive

此分類上一篇: Aspose.Zip.Tar.TarArchive

Remarks

GZip提取流因压缩算法的性质而不可寻找。Tar 存档提供了随意提取记录的方便,因此它必须在洞下运行可搜索的流。

Exceptions

ArgumentNullException

path’ is null.

ArgumentException

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

UnauthorizedAccessException

拒绝访问 path" 文件。

PathTooLongException

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

NotSupportedException

文件在 path’ 是无效格式。

DirectoryNotFoundException

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

FileNotFoundException

文件未找到。

InvalidDataException

档案被腐败了。

从LZ4(线条)

提取物提供 LZ4 档案和构成 Aspose.Zip.Tar.tarArchive 从获取的数据。

重要: LZ4 存档是完全提取在这个方法,其内容是内部保存。

public static TarArchive FromLZ4(string path)

Parameters

path string

走向档案的路径。

Returns

TarArchive

此分類上一篇: Aspose.Zip.Tar.TarArchive

Remarks

LZ4提取流因压缩算法的性质而不可寻找,Tar档案提供了随意提交记录的便利性,因此必须在尾巴下运行可寻求流。

Exceptions

ArgumentNullException

path’ is null.

SecurityException

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

ArgumentException

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

UnauthorizedAccessException

拒绝访问 path" 文件。

PathTooLongException

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

NotSupportedException

文件在 path’ 是无效格式。

DirectoryNotFoundException

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

FileNotFoundException

文件未找到。

EndOfStreamException

文件太短了。

InvalidDataException

文件有错误的签名。

从LZ4(Stream)

提取物提供 LZ4 档案和构成 Aspose.Zip.Tar.tarArchive 从获取的数据。

重要: LZ4 存档是完全提取在这个方法,其内容是内部保存。

public static TarArchive FromLZ4(Stream source)

Parameters

source Stream

档案的来源。

Returns

TarArchive

此分類上一篇: Aspose.Zip.Tar.TarArchive

Remarks

LZ4提取流因压缩算法的性质而不可寻找,Tar档案提供了随意提交记录的便利性,因此必须在尾巴下运行可寻求流。

Exceptions

ArgumentException

不能从 source’ 阅读

ArgumentNullException

source’ is null.

EndOfStreamException

source’ is too short.

InvalidDataException

source" 有错误的签名。

从LZMA(Stream)

提取的 LZMA 档案和组成 Aspose.Zip.Tar.TarArchive 从提取的数据。

重要:LZMA档案在这个方法中完全提取,其内容被内部保存。

public static TarArchive FromLZMA(Stream source)

Parameters

source Stream

档案的来源。

Returns

TarArchive

此分類上一篇: Aspose.Zip.Tar.TarArchive

Remarks

LZMA提取流因压缩算法的性质而不可寻找,Tar档案提供了随意提取记录的便利性,因此必须在尾巴下运行可寻找流。

Exceptions

InvalidDataException

档案被腐败了。

从LZMA(线条)

提取的 LZMA 档案和组成 Aspose.Zip.Tar.TarArchive 从提取的数据。

重要:LZMA档案在这个方法中完全提取,其内容被内部保存。

public static TarArchive FromLZMA(string path)

Parameters

path string

走向档案的路径。

Returns

TarArchive

此分類上一篇: Aspose.Zip.Tar.TarArchive

Remarks

LZMA提取流因压缩算法的性质而不可寻找,Tar档案提供可自愿提交记录的便利性,因此必须在尾巴下运行可寻求流。

Exceptions

ArgumentNullException

path’ is null.

ArgumentException

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

UnauthorizedAccessException

拒绝访问 path" 文件。

PathTooLongException

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

NotSupportedException

文件在 path’ 是无效格式。

DirectoryNotFoundException

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

FileNotFoundException

文件未找到。

从LZIP(Stream)

提取的 lzip 档案和组成 Aspose.Zip.Tar.TarArchive 从提取的数据。

重要: lzip 档案在此方法中完全提取,其内容在内部保留。

public static TarArchive FromLZip(Stream source)

Parameters

source Stream

档案的来源。

Returns

TarArchive

此分類上一篇: Aspose.Zip.Tar.TarArchive

Remarks

Lzip 提取流因压缩算法的性质而不可寻找,Tar 档案提供了随意提取记录的便利性,因此必须在洞下运行可寻找流。

Exceptions

InvalidDataException

档案被腐败了。

ArgumentException

source’ is not seekable.

ArgumentNullException

source’ is null.

从LZIP(线条)

提取的 lzip 档案和组成 Aspose.Zip.Tar.TarArchive 从提取的数据。

重要: lzip 档案在此方法中完全提取,其内容在内部保留。

public static TarArchive FromLZip(string path)

Parameters

path string

走向档案的路径。

Returns

TarArchive

此分類上一篇: Aspose.Zip.Tar.TarArchive

Remarks

Lzip 提取流因压缩算法的性质而不可寻找,Tar 档案提供了随意提取记录的便利性,因此必须在洞下运行可寻找流。

Exceptions

ArgumentNullException

path’ is null.

ArgumentException

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

UnauthorizedAccessException

拒绝访问 path" 文件。

PathTooLongException

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

NotSupportedException

文件在 path’ 是无效格式。

DirectoryNotFoundException

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

FileNotFoundException

文件未找到。

InvalidDataException

档案被腐败了。

FromXz(Stream)

提取的 xz 格式档案和组成 Aspose.Zip.Tar.TarArchive 从提取的数据。

重要: xz 存档是完全提取在这个方法,其内容是内部保存。

public static TarArchive FromXz(Stream source)

Parameters

source Stream

档案的来源。

Returns

TarArchive

此分類上一篇: Aspose.Zip.Tar.TarArchive

Remarks

Tar 存档提供了随意提取记录的方便,因此它必须在洞下运行可搜索的流。

FromXz(线条)

提取的 xz 格式档案和组成 Aspose.Zip.Tar.TarArchive 从提取的数据。

重要: xz 存档是完全提取在这个方法,其内容是内部保存。

public static TarArchive FromXz(string path)

Parameters

path string

走向档案的路径。

Returns

TarArchive

此分類上一篇: Aspose.Zip.Tar.TarArchive

Remarks

Tar 存档提供了随意提取记录的方便,因此它必须在洞下运行可搜索的流。

Exceptions

ArgumentNullException

path’ is null.

ArgumentException

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

UnauthorizedAccessException

拒绝访问 path" 文件。

PathTooLongException

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

NotSupportedException

文件在 path’ 是无效格式。

DirectoryNotFoundException

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

FileNotFoundException

文件未找到。

从Z(Stream)

提取的 Z 格式档案和组成 Aspose.Zip.Tar.TarArchive 从提取的数据。

重要: Z 档案是完全提取在这个方法,其内容是内部保存。

public static TarArchive FromZ(Stream source)

Parameters

source Stream

档案的来源。

Returns

TarArchive

此分類上一篇: Aspose.Zip.Tar.TarArchive

Remarks

Tar 存档提供了随意提取记录的方便,因此它必须在洞下运行可搜索的流。

从Z(线条)

提取的 Z 格式档案和组成 Aspose.Zip.Tar.TarArchive 从提取的数据。

重要: Z 档案是完全提取在这个方法,其内容是内部保存。

public static TarArchive FromZ(string path)

Parameters

path string

走向档案的路径。

Returns

TarArchive

此分類上一篇: Aspose.Zip.Tar.TarArchive

Remarks

Tar 存档提供了随意提取记录的方便,因此它必须在洞下运行可搜索的流。

Exceptions

ArgumentNullException

path’ is null.

ArgumentException

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

UnauthorizedAccessException

拒绝访问 path" 文件。

PathTooLongException

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

NotSupportedException

文件在 path’ 是无效格式。

DirectoryNotFoundException

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

FileNotFoundException

文件未找到。

FromZstandard(Stream)

提取的 Zstandard 档案和构成 Aspose.Zip.Tar.TarArchive 从提取的数据。

重要: Zstandard 存档是完全提取在这个方法,其内容是内部保存。

public static TarArchive FromZstandard(Stream source)

Parameters

source Stream

档案的来源。

Returns

TarArchive

此分類上一篇: Aspose.Zip.Tar.TarArchive

Exceptions

IOException

Zstandard 流是腐败的或不可读的。

InvalidDataException

数据是腐败的。

FromZstandard(线条)

提取的 Zstandard 档案和构成 Aspose.Zip.Tar.TarArchive 从提取的数据。

重要: Zstandard 存档是完全提取在这个方法,其内容是内部保存。

public static TarArchive FromZstandard(string path)

Parameters

path string

走向档案的路径。

Returns

TarArchive

此分類上一篇: Aspose.Zip.Tar.TarArchive

Exceptions

ArgumentNullException

path’ is null.

ArgumentException

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

UnauthorizedAccessException

拒绝访问 path" 文件。

PathTooLongException

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

NotSupportedException

文件在 path’ 是无效格式。

DirectoryNotFoundException

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

FileNotFoundException

文件未找到。

IOException

Zstandard 流是腐败的或不可读的。

InvalidDataException

数据是腐败的。

Save(流量,TarFormat?)

存储存档到提供的流量。

public void Save(Stream output, TarFormat? format = null)

Parameters

output Stream

目的地流

format TarFormat ?

定义 tar 标题格式. Null 值在可能时将被视为 USTar。

Examples

using (FileStream tarFile = File.Open("archive.tar", FileMode.Create))
{
    using (var archive = new TarArchive())
    {
        archive.CreateEntry("entry1", "data.bin");
        archive.Save(tarFile);
    }
}

Remarks

必须是可写的。

Exceptions

ArgumentException

output’ is not writable. - or - output’ is the same stream we extract from.- OR -It is impossible to save archive in format’ due to format restrictions.

Save(字符串,字符串?)

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

public void Save(string destinationFileName, TarFormat? format = null)

Parameters

destinationFileName string

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

format TarFormat ?

定义 tar 标题格式. Null 值在可能时将被视为 USTar。

Examples

using (var archive = new TarArchive())
{
    archive.CreateEntry("entry1", "data.bin");        
    archive.Save("myarchive.tar");
}

Remarks

可以将档案存储到它从下载的同一条路径,但是,这并不建议,因为这种方法使用复制到临时文件。

Exceptions

ArgumentException

destinationFileName’ is a zero-length string, contains only white space, or contains one or more invalid characters as defined by System.IO.Path.InvalidPathChars.

ArgumentNullException

destinationFileName’ is null.

PathTooLongException

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

DirectoryNotFoundException

指定的 destinationFileName’ 是无效的,(例如,它在一个未地图的驱动器上)。

IOException

在打开文件时出现了 I/O 错误。

UnauthorizedAccessException

destinationFileName’ specified a file that is read-only and access is not Read.-or- path specified a directory.-or- The caller does not have the required permission.

NotSupportedException

destinationFileName’ is in an invalid format.

FileNotFoundException

文件未找到。

SaveGzipped(流量,TarFormat?)

通过 gzip 压缩,存储存档到流。

public void SaveGzipped(Stream output, TarFormat? format = null)

Parameters

output Stream

目的地流

format TarFormat ?

定义 tar 标题格式. Null 值在可能时将被视为 USTar。

Examples

using (FileStream result = File.OpenWrite("result.tar.gz"))
{
    using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
    {
        using (var archive = new TarArchive())
        {
            archive.CreateEntry("entry.bin", source);
            archive.SaveGzipped(result);
        }
    }
}

Remarks

必须是可写的。

Exceptions

ArgumentNullException

output’ is null.

ArgumentException

output’ is not writable.

SaveGzipped(字符串,字符串?)

通过 gzip 压缩将文件存储到文件中。

public void SaveGzipped(string path, TarFormat? format = null)

Parameters

path string

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

format TarFormat ?

定义 tar 标题格式. Null 值在可能时将被视为 USTar。

Examples

using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
{
    using (var archive = new TarArchive())
    {
        archive.CreateEntry("entry.bin", source);
        archive.SaveGzipped("result.tar.gz");
    }
}

Exceptions

UnauthorizedAccessException

呼叫者没有所需的许可。 -or- path’ 指定一个仅阅读的文件或目录。

ArgumentException

path’ is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.

ArgumentNullException

path’ is null.

PathTooLongException

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

DirectoryNotFoundException

指定的 path’ 是无效的,(例如,它在一个未地图的驱动器上)。

NotSupportedException

path’ is in an invalid format.

SaveLZ4 压缩(流量,TarFormat?)

通过 LZ4 压缩,存储存档到流。

public void SaveLZ4Compressed(Stream output, TarFormat? format = null)

Parameters

output Stream

目的地流

format TarFormat ?

定义 tar 标题格式. Null 值在可能时将被视为 USTar。

Examples

using (FileStream result = File.OpenWrite("result.tar.lz4"))
{
    using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
    {
        using (var archive = new TarArchive())
        {
            archive.CreateEntry("entry.bin", source);
            archive.SaveLZ4Compressed(result);
        }
    }
}

Remarks

必须是可写的。

Exceptions

ArgumentNullException

output’ is null.

ArgumentException

output’ is not writable.

SaveLZ4 压缩(字符串,字符串?)

通过 LZ4 压缩存储到文件的路径。

public void SaveLZ4Compressed(string path, TarFormat? format = null)

Parameters

path string

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

format TarFormat ?

定义 tar 标题格式. Null 值在可能时将被视为 USTar。

Examples

using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
{
    using (var archive = new TarArchive())
    {
        archive.CreateEntry("entry.bin", source);
        archive.SaveLZ4Compressed("result.tar.lz4");
    }
}

Exceptions

UnauthorizedAccessException

呼叫者没有所需的许可。 -or- path’ 指定一个仅阅读的文件或目录。

ArgumentException

path’ is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.

ArgumentNullException

path’ is null.

PathTooLongException

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

DirectoryNotFoundException

指定的 path’ 是无效的,(例如,它在一个未地图的驱动器上)。

NotSupportedException

path’ is in an invalid format.

安慰 压缩(流量,TarFormat?)

通过 LZMA 压缩,存储存档到流。

public void SaveLZMACompressed(Stream output, TarFormat? format = null)

Parameters

output Stream

目的地流

format TarFormat ?

定义 tar 标题格式. Null 值在可能时将被视为 USTar。

Examples

using (FileStream result = File.OpenWrite("result.tar.lzma"))
{
    using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
    {
        using (var archive = new TarArchive())
        {
            archive.CreateEntry("entry.bin", source);
            archive.SaveLZMACompressed(result);
        }
    }
}

Remarks

必须是可写的。

重要: tar 档案是由此组成,然后在这个方法中压缩,其内容是内部保存的。

Exceptions

ArgumentNullException

output’ is null.

ArgumentException

output’ is not writable.

安慰 压缩(字符串,字符串?)

通过 lzma 压缩将文件存储到文件中。

public void SaveLZMACompressed(string path, TarFormat? format = null)

Parameters

path string

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

format TarFormat ?

定义 tar 标题格式. Null 值在可能时将被视为 USTar。

Examples

using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
{
    using (var archive = new TarArchive())
    {
        archive.CreateEntry("entry.bin", source);
        archive.SaveLZMACompressed("result.tar.lzma");
    }
}

Remarks

重要: tar 档案是由此组成,然后在这个方法中压缩,其内容是内部保存的。

Exceptions

UnauthorizedAccessException

呼叫者没有所需的许可。 -or- path’ 指定一个仅阅读的文件或目录。

ArgumentException

path’ is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.

ArgumentNullException

path’ is null.

PathTooLongException

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

DirectoryNotFoundException

指定的 path’ 是无效的,(例如,它在一个未地图的驱动器上)。

NotSupportedException

path’ is in an invalid format.

SaveLzipped(流量,TarFormat?)

通过 lzip 压缩,存储存档到流。

public void SaveLzipped(Stream output, TarFormat? format = null)

Parameters

output Stream

目的地流

format TarFormat ?

定义 tar 标题格式. Null 值在可能时将被视为 USTar。

Examples

using (FileStream result = File.OpenWrite("result.tar.lz"))
{
    using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
    {
        using (var archive = new TarArchive())
        {
            archive.CreateEntry("entry.bin", source);
            archive.SaveLzipped(result);
        }
    }
}

Remarks

必须是可写的。

Exceptions

ArgumentNullException

output’ is null.

ArgumentException

output’ is not writable.

SaveLzipped(字符串,字符串?)

通过 lzip 压缩将文件存储到文件中。

public void SaveLzipped(string path, TarFormat? format = null)

Parameters

path string

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

format TarFormat ?

定义 tar 标题格式. Null 值在可能时将被视为 USTar。

Examples

using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
{
    using (var archive = new TarArchive())
    {
        archive.CreateEntry("entry.bin", source);
        archive.SaveGzipped("result.tar.lz");
    }
}

Exceptions

UnauthorizedAccessException

呼叫者没有所需的许可。 -or- path’ 指定一个仅阅读的文件或目录。

ArgumentException

path’ is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.

ArgumentNullException

path’ is null.

PathTooLongException

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

DirectoryNotFoundException

指定的 path’ 是无效的,(例如,它在一个未地图的驱动器上)。

NotSupportedException

path’ is in an invalid format.

SaveXzCompressed(流, TarFormat?, XzArchiveSettings)

存储存档以 xz 压缩到流。

public void SaveXzCompressed(Stream output, TarFormat? format = null, XzArchiveSettings settings = null)

Parameters

output Stream

目的地流

format TarFormat ?

定义 tar 标题格式. Null 值在可能时将被视为 USTar。

settings XzArchiveSettings

设置特定 xz 档案:字典大小,区块大小,检查类型。

Examples

using (FileStream result = File.OpenWrite("result.tar.xz"))
{
    using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
    {
        using (var archive = new TarArchive())
        {
            archive.CreateEntry("entry.bin", source);
            archive.SaveXzCompressed(result);
        }
    }
}

Remarks

流量必须是可写的。

Exceptions

ArgumentNullException

output’ is null.

ArgumentException

output’ is not writable.

SaveXzCompressed(字符串, TarFormat?, XzArchiveSettings)

通过 xz 压缩存储到路径的档案。

public void SaveXzCompressed(string path, TarFormat? format = null, XzArchiveSettings settings = null)

Parameters

path string

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

format TarFormat ?

定义 tar 标题格式. Null 值在可能时将被视为 USTar。

settings XzArchiveSettings

设置特定 xz 档案:字典大小,区块大小,检查类型。

Examples

using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
{
    using (var archive = new TarArchive())
    {
        archive.CreateEntry("entry.bin", source);
        archive.SaveXzCompressed("result.tar.xz");
    }
}

Exceptions

UnauthorizedAccessException

呼叫者没有所需的许可。 -or- path’ 指定一个仅阅读的文件或目录。

ArgumentException

path’ is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.

ArgumentNullException

path’ is null.

PathTooLongException

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

DirectoryNotFoundException

指定的 path’ 是无效的,(例如,它在一个未地图的驱动器上)。

NotSupportedException

path’ is in an invalid format.

SaveZ压缩(流量,TarFormat?)

通过 Z 压缩存储存档到流。

public void SaveZCompressed(Stream output, TarFormat? format = null)

Parameters

output Stream

目的地流

format TarFormat ?

定义 tar 标题格式. Null 值在可能时将被视为 USTar。

Examples

using (FileStream result = File.OpenWrite("result.tar.Z"))
{
    using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
    {
        using (var archive = new TarArchive())
        {
            archive.CreateEntry("entry.bin", source);
            archive.SaveZCompressed(result);
        }
    }
}

Remarks

必须是可写的。

Exceptions

ArgumentNullException

output’ is null.

ArgumentException

output’ is not writable.

SaveZ压缩(字符串,字符串?)

通过 Z 压缩存储到路径的档案。

public void SaveZCompressed(string path, TarFormat? format = null)

Parameters

path string

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

format TarFormat ?

定义 tar 标题格式. Null 值在可能时将被视为 USTar。

Examples

using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
{
    using (var archive = new TarArchive())
    {
        archive.CreateEntry("entry.bin", source);
        archive.SaveZCompressed("result.tar.Z");
    }
}

Exceptions

UnauthorizedAccessException

呼叫者没有所需的许可。 -or- path’ 指定一个仅阅读的文件或目录。

ArgumentException

path’ is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.

ArgumentNullException

path’ is null.

PathTooLongException

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

DirectoryNotFoundException

指定的 path’ 是无效的,(例如,它在一个未地图的驱动器上)。

NotSupportedException

path’ is in an invalid format.

SaveZstandard(流量,TarFormat?)

存储存档到流量,使用Zstandard压缩。

public void SaveZstandard(Stream output, TarFormat? format = null)

Parameters

output Stream

目的地流

format TarFormat ?

定义 tar 标题格式. Null 值在可能时将被视为 USTar。

Examples

using (FileStream result = File.OpenWrite("result.tar.zst"))
{
    using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
    {
        using (var archive = new TarArchive())
        {
            archive.CreateEntry("entry.bin", source);
            archive.SaveZstandard(result);
        }
    }
}

Remarks

必须是可写的。

Exceptions

ArgumentNullException

output’ is null.

ArgumentException

output’ is not writable.

SaveZstandard(字符串,字符串?)

通过 Zstandard 压缩将文件存储到文件中。

public void SaveZstandard(string path, TarFormat? format = null)

Parameters

path string

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

format TarFormat ?

定义 tar 标题格式. Null 值在可能时将被视为 USTar。

Examples

using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
{
    using (var archive = new TarArchive())
    {
        archive.CreateEntry("entry.bin", source);
        archive.SaveZstandard("result.tar.zst");
    }
}

Exceptions

UnauthorizedAccessException

呼叫者没有所需的许可。 -or- path’ 指定一个仅阅读的文件或目录。

ArgumentException

path’ is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.

ArgumentNullException

path’ is null.

PathTooLongException

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

DirectoryNotFoundException

指定的 path’ 是无效的,(例如,它在一个未地图的驱动器上)。

NotSupportedException

path’ is in an invalid format.

 中文