ZstandardArchive.Save

Save(Stream, ZstandardSaveOptions)

Saves archive to the stream provided.

public void Save(Stream outputStream, ZstandardSaveOptions settings = null)
ParameterTypeDescription
outputStreamStreamDestination stream.
settingsZstandardSaveOptionsOptional settings for archive composition.

Exceptions

exceptioncondition
ObjectDisposedExceptionArchive has been disposed and cannot be used.
ArgumentExceptionoutputStream is not writable.
InvalidOperationExceptionSource has not been supplied.

Remarks

outputStream must be writable.

Examples

Write compressed data to http response stream.

using (var archive = new ZstandardArchive()) 
{
    archive.SetSource(new FileInfo("data.bin"));
    archive.Save(httpResponse.OutputStream);
}

See Also


Save(string, ZstandardSaveOptions)

Saves archive to the destination file provided.

public void Save(string destinationFileName, ZstandardSaveOptions settings = null)
ParameterTypeDescription
destinationFileNameStringThe path of the archive to be created. If the specified file name points to an existing file, it will be overwritten.
settingsZstandardSaveOptionsOptional settings for archive composition.

Exceptions

exceptioncondition
ObjectDisposedExceptionArchive has been disposed and cannot be used.
ArgumentNullExceptiondestinationFileName is null.
SecurityExceptionThe caller does not have the required permission to access.
ArgumentExceptionThe destinationFileName is empty, contains only white spaces, or contains invalid characters.
UnauthorizedAccessExceptionAccess to file destinationFileName is denied.
PathTooLongExceptionThe specified destinationFileName, 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 destinationFileName contains a colon (:) in the middle of the string.

Examples

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

See Also


Save(FileInfo, ZstandardSaveOptions)

Saves archive to the destination file provided.

public void Save(FileInfo destination, ZstandardSaveOptions settings = null)
ParameterTypeDescription
destinationFileInfoFileInfo, which will be opened as destination stream.
settingsZstandardSaveOptionsOptional settings for archive composition.

Exceptions

exceptioncondition
ObjectDisposedExceptionArchive has been disposed and cannot be used.
SecurityExceptionThe caller does not have the required permission to open the destination.
ArgumentExceptionThe file path is empty or contains only white spaces.
FileNotFoundExceptionThe file is not found.
UnauthorizedAccessExceptionPath to file is read-only or is a directory.
ArgumentNullExceptiondestination is null.
DirectoryNotFoundExceptionThe specified path is invalid, such as being on an unmapped drive.
IOExceptionThe file is already open.

Examples

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

See Also