ZstandardArchive

ZstandardArchive constructor (1 of 3)

Initializes a new instance of the ZstandardArchive class prepared for compressing.

public ZstandardArchive()

Examples

The following example shows how to compress a file.

using (ZstandardArchive archive = new ZstandardArchive()) 
{
    archive.SetSource("data.bin");
    archive.Save("archive.zst");
}

See Also


ZstandardArchive constructor (2 of 3)

Initializes a new instance of the ZstandardArchive class prepared for decompressing.

public ZstandardArchive(Stream sourceStream)
ParameterTypeDescription
sourceStreamStreamThe source of the archive.

Remarks

This constructor does not decompress. See Open method for decompressing.

Examples

Open an archive from a stream and extract it to a MemoryStream

var ms = new MemoryStream();
using (GzipArchive archive = new ZstandardArchive(File.OpenRead("archive.zst")))
  archive.Open().CopyTo(ms);

See Also


ZstandardArchive constructor (3 of 3)

Initializes a new instance of the ZstandardArchive class.

public ZstandardArchive(string path, bool parseHeader = false)
ParameterTypeDescription
pathStringThe path to the archive file.
parseHeaderBooleanWhether to parse stream header to figure out properties, including name. Makes sense for seekable stream only.

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.

Remarks

This constructor does not decompress. See Open method for decompressing.

Examples

Open an archive from file by path and extract it to a MemoryStream

var ms = new MemoryStream();
using (ZstandardArchive archive = new ZstandardArchive("archive.zst"))
  archive.Open().CopyTo(ms);

See Also