ZstandardArchive.ZstandardArchive

ZstandardArchive()

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(Stream, ZstandardLoadOptions)

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

public ZstandardArchive(Stream sourceStream, ZstandardLoadOptions options = null)
ParameterTypeDescription
sourceStreamStreamThe source of the archive.
optionsZstandardLoadOptionsThe options to load archive with.

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(string, ZstandardLoadOptions)

Initializes a new instance of the ZstandardArchive class.

public ZstandardArchive(string path, ZstandardLoadOptions options = null)
ParameterTypeDescription
pathStringThe path to the archive file.
optionsZstandardLoadOptionsThe options to load archive with.

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