Class ArchiveFactory
名称: Aspose.Zip 收藏: Aspose.Zip.dll (25.5.0)
检测存档格式并根据存档类型创建适当的 Aspose.Zip.IArchive 对象。
public static class ArchiveFactory
Inheritance
继承人
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Methods
CompressDirectory(字符串,字符串, ArchiveFormat)
将指定的目录压缩到使用提供的档案格式的档案文件中。
public static void CompressDirectory(string path, string outputFileName, ArchiveFormat archiveFormat)
Parameters
path
string
走向将压缩的目录的路径。
outputFileName
string
目的地文件名称
archiveFormat
ArchiveFormat
要创建的档案格式(例如,Zip、Rar、Tar等)。
Examples
下面是如何使用CompressDirectory方法的例子:
string directoryPath = @"C:\path\to\your\directory";
ArchiveInfo.ArchiveFormat format = ArchiveInfo.ArchiveFormat.Zip;
ArchiveFactory.CompressDirectory(directoryPath, "result", format);
// This will create a zip file with the contents of the directory at the specified path.
Remarks
此方法将创建一个档案文件,以 path’ 参数所指定的位置。档案文件的名称通常是由适当的文件扩展基于
archiveFormat’. 该文件的名称不会被修改或删除。
Exceptions
如果 path" 所指定的目录不存在。
如果 path’ 是 null 或是空行。
如果所指定的 archiveFormat’ 不受支持或认可。
GetArchive(线条)
检测存档格式并根据指定的路径所指定的存档类型创建适当的 Aspose.Zip.IArchive 对象。
public static IArchive GetArchive(string path)
Parameters
path
string
要分析到档案的路径。
Returns
一个 Aspose.Zip.IArchive 对象代表档案。
GetArchive(Stream)
检测存档格式并根据该流所指定的存档类型创建适当的 Aspose.Zip.IArchive 对象。
public static IArchive GetArchive(Stream stream)
Parameters
stream
Stream
包含档案数据的流量,必须可搜索。
Returns
一个 Aspose.Zip.IArchive 对象代表档案。
GetArchive(流, string)
检测存档格式并根据该流所指定的加密存档类型创建适当的 Aspose.Zip.IArchive 对象。
public static IArchive GetArchive(Stream stream, string password)
Parameters
stream
Stream
包含档案数据的流量,必须可搜索。
password
string
密码来解密加密档案。
Returns
一个 Aspose.Zip.IArchive 对象代表档案。