Extract

CabEntry.Extract method (1 of 2)

Extracts the entry to the filesystem by the path provided.

public FileInfo Extract(string path)
ParameterTypeDescription
pathStringThe path to destination file. If the file already exists, it will be overwritten.

Return Value

The file info of composed 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.
NotSupportedExceptionStream initialization failed due to wrong data.
InvalidDataExceptionArchive is corrupted.

Examples

using (var archive = new CabArchive("archive.cab"))
{
    archive.Entries[0].Extract("data.bin");
}

See Also


CabEntry.Extract method (2 of 2)

Extracts the entry to the stream provided.

public void Extract(Stream destination)
ParameterTypeDescription
destinationStreamDestination stream. Must be writable.

Exceptions

exceptioncondition
ArgumentExceptiondestination does not support writing.
NotSupportedExceptionStream initialization failed due to wrong data.
InvalidDataExceptionArchive is corrupted.

Examples

Extract an entry of cab archive.

using (var archive = new CabArchive("archive.cab"))
{
    archive.Entries[0].Extract(httpResponseStream);
}

See Also