Class CabArchive
Namespace: Aspose.Zip.Cab
Assembly: Aspose.Zip.dll (25.8.0)
This class represents a cab archive file.
public class CabArchive : IArchive, IDisposableInheritance
Implements
Inherited Members
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Constructors
CabArchive(Stream, CabLoadOptions)
Initializes a new instance of the Aspose.Zip.Cab.CabArchive class and composes an entry list can be extracted from the archive.
public CabArchive(Stream sourceStream, CabLoadOptions loadOptions = null)Parameters
sourceStream Stream
The source of the archive. It must be seekable.
loadOptions CabLoadOptions
Examples
The following example shows how to extract all the entries to a directory.
using (var archive = new CabArchive(File.OpenRead("archive.cab")))
{
archive.ExtractToDirectory("C:\extracted");
}Remarks
This constructor does not unpack any entry. See Aspose.Zip.Cab.CabEntry.Open method for unpacking.
Exceptions
sourceStream is null.
sourceStream is not seekable.
sourceStream is not valid cab archive.
The stream is too short.
CabArchive(string, CabLoadOptions)
Initializes a new instance of the Aspose.Zip.Cab.CabArchive class and composes an entry list can be extracted from the archive.
public CabArchive(string path, CabLoadOptions loadOptions = null)Parameters
path string
The path to the archive file.
loadOptions CabLoadOptions
Examples
The following example shows how to extract all the entries to a directory.
using (var archive = new CabArchive("archive.cab"))
{
archive.ExtractToDirectory("C:\extracted");
}Remarks
This constructor does not unpack any entry. See Aspose.Zip.Cab.CabEntry.Open method for unpacking.
Exceptions
path is null.
The caller does not have the required permission to access.
The path is empty, contains only white spaces, or contains invalid characters.
Access to file path is denied.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
File at path contains a colon (:) in the middle of the string.
The file is not found.
The specified path is invalid, such as being on an unmapped drive.
The file is already open.
The file is too short.
Properties
Entries
Gets entries of Aspose.Zip.Cab.CabEntry type constituting the archive.
public ReadOnlyCollection<cabentry> Entries { get; }Property Value
ReadOnlyCollection < CabEntry >
Exceptions
Archive has been disposed and cannot be used.
Methods
Dispose(bool)
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
protected virtual void Dispose(bool disposing)Parameters
disposing bool
Whether managed resources should be disposed.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()ExtractToDirectory(string)
Extracts all the files in the archive to the directory provided.
public void ExtractToDirectory(string destinationDirectory)Parameters
destinationDirectory string
The path to the directory to place the extracted files in.
Examples
using (var archive = new CabArchive("archive.cab"))
{
archive.ExtractToDirectory("C:\extracted");
}Remarks
If the directory does not exist, it will be created.
Exceptions
path is null
The specified path, file name, or both exceed the system-defined maximum length.
The caller does not have the required permission to access the existing directory.
If the directory does not exist, a path contains a colon character (:) that is not part of a drive label (“C:").
path 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 (:).
The directory specified by path is a file. -or- The network name is not known.
The archive is corrupted.
Archive has been disposed and cannot be used.
In .NET Framework 4.0 and above: Thrown when the extraction is canceled via the provided cancellation token.