TarArchive.SaveXzCompressed

SaveXzCompressed(Stream, TarFormat?, XzArchiveSettings)

Saves archive to the stream with xz compression.

public void SaveXzCompressed(Stream output, TarFormat? format = default, 
    XzArchiveSettings settings = null)
ParameterTypeDescription
outputStreamDestination stream.
formatNullable`1Defines the tar header format. Null value will be treated as USTar when possible.
settingsXzArchiveSettingsSet of setting particular xz archive: dictionary size, block size, check type.

Exceptions

exceptioncondition
ArgumentNullExceptionoutput is null.
ArgumentExceptionoutput is not writable.

Remarks

outputThe stream must be writable.

Examples

using (FileStream result = File.OpenWrite("result.tar.xz"))
{
    using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
    {
        using (var archive = new TarArchive())
        {
            archive.CreateEntry("entry.bin", source);
            archive.SaveXzCompressed(result);
        }
    }
}

See Also


SaveXzCompressed(string, TarFormat?, XzArchiveSettings)

Saves archive to the path by path with xz compression.

public void SaveXzCompressed(string path, TarFormat? format = default, 
    XzArchiveSettings settings = null)
ParameterTypeDescription
pathStringThe path of the archive to be created. If the specified file name points to an existing file, it will be overwritten.
formatNullable`1Defines the tar header format. Null value will be treated as USTar when possible.
settingsXzArchiveSettingsSet of setting particular xz archive: dictionary size, block size, check type.

Exceptions

exceptioncondition
UnauthorizedAccessExceptionThe caller does not have the required permission. -or- path specified a read-only file or directory.
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.
ArgumentNullExceptionpath is null.
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.
DirectoryNotFoundExceptionThe specified path is invalid, (for example, it is on an unmapped drive).
NotSupportedExceptionpath is in an invalid format.

Examples

using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
{
    using (var archive = new TarArchive())
    {
        archive.CreateEntry("entry.bin", source);
        archive.SaveXzCompressed("result.tar.xz");
    }
}

See Also