CabArchive

CabArchive constructor (1 of 2)

Initializes a new instance of the CabArchive class and composes entries list can be extracted from the archive.

public CabArchive(Stream sourceStream)
ParameterTypeDescription
sourceStreamStreamThe source of the archive. It must be seekable.

Exceptions

exceptioncondition
ArgumentNullExceptionsourceStream is null.
ArgumentExceptionsourceStream is not seekable.
InvalidDataExceptionsourceStream is not valid cab archive.
EndOfStreamExceptionStream is too short.

Remarks

This constructor does not unpack any entry. See Open method for unpacking.

Examples

The following example shows how to extract all of the entries to a directory.

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

See Also


CabArchive constructor (2 of 2)

Initializes a new instance of the CabArchive class and composes entries list can be extracted from the archive.

public CabArchive(string path)
ParameterTypeDescription
pathStringThe path to the archive file.

Exceptions

exceptioncondition
ArgumentNullExceptionpath is null.
SecurityExceptionThe caller does not have the required permission to access.
ArgumentExceptionThe path is empty, contains only white spaces, or contains invalid characters.
UnauthorizedAccessExceptionAccess to file path is denied.
PathTooLongExceptionThe 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.
NotSupportedExceptionFile at path contains a colon (:) in the middle of the string.
FileNotFoundExceptionThe file is not found.
DirectoryNotFoundExceptionThe specified path is invalid, such as being on an unmapped drive.
IOExceptionThe file is already open.
EndOfStreamExceptionFile is too short.

Remarks

This constructor does not unpack any entry. See Open method for unpacking.

Examples

The following example shows how to extract all of the entries to a directory.

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

See Also