XzArchive.Extract
Extracts xz archive to a stream.
public void Extract(Stream destination)
| Parameter | Type | Description |
|---|
| destination | Stream | Stream for storing decompressed data. |
Exceptions
| exception | condition |
|---|
| ObjectDisposedException | Archive has been disposed and cannot be used. |
| InvalidOperationException | Archive headers and service information were not read. |
| OperationCanceledException | In .NET Framework 4.0 and above: Thrown when the extraction is canceled via the provided cancellation token. |
Examples
using (FileStream xzFile = File.Open(sourceFileName, FileMode.Open))
{
using (FileStream extractedFile = File.Open(extractedFileName, FileMode.Create))
{
using (var archive = new XzArchive(xzFile))
{
archive.Extract(extractedFile);
}
}
}
See Also
Extracts xz archive to a file.
public void Extract(FileInfo fileInfo)
| Parameter | Type | Description |
|---|
| fileInfo | FileInfo | FileInfo for storing decompressed data. |
Exceptions
| exception | condition |
|---|
| ObjectDisposedException | Archive has been disposed and cannot be used. |
| InvalidOperationException | Archive headers and service information were not read. |
| SecurityException | The caller does not have the required permission to open the fileInfo. |
| ArgumentException | The file path is empty or contains only white spaces. |
| FileNotFoundException | The file is not found. |
| UnauthorizedAccessException | Path to file is read-only or is a directory. |
| ArgumentNullException | fileInfo is null. |
| DirectoryNotFoundException | The specified path is invalid, such as being on an unmapped drive. |
| IOException | The file is already open. |
| OperationCanceledException | In .NET Framework 4.0 and above: Thrown when the extraction is canceled via the provided cancellation token. |
Examples
using (FileStream xzFile = File.Open(sourceFileName, FileMode.Open))
{
using (var archive = new XzArchive(xzFile))
{
archive.Extract(new FileInfo("extracted.bin"));
}
}
See Also
Extracts xz archive to a file by path.
public FileInfo Extract(string path)
| Parameter | Type | Description |
|---|
| path | String | Path to file which will store decompressed data. |
Return Value
FileInfo instance containing extracted data.
Exceptions
| exception | condition |
|---|
| ObjectDisposedException | Archive has been disposed and cannot be used. |
| InvalidOperationException | Archive headers and service information were not read. |
| ArgumentNullException | path is null. |
| SecurityException | The caller does not have the required permission to access. |
| ArgumentException | The path is empty, contains only white spaces, or contains invalid characters. |
| UnauthorizedAccessException | Access to file path is denied. |
| PathTooLongException | 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. |
| NotSupportedException | File at path contains a colon (:) in the middle of the string. |
| FileNotFoundException | The file is not found. |
| DirectoryNotFoundException | The specified path is invalid, such as being on an unmapped drive. |
| IOException | The file is already open. |
| OperationCanceledException | In .NET Framework 4.0 and above: Thrown when the extraction is canceled via the provided cancellation token. |
Examples
using (FileStream xzFile = File.Open(sourceFileName, FileMode.Open))
{
using (var archive = new XzArchive(xzFile))
{
archive.Extract("extracted.bin");
}
}
See Also