Lz4Archive.Save

Save(Stream)

Saves lz4 archive to the stream provided.

public void Save(Stream output)
ParameterTypeDescription
outputStreamDestination stream.

Exceptions

exceptioncondition
ArgumentNullExceptionoutput is null.
ArgumentExceptionoutput is not writable.
InvalidOperationExceptionThe archive is prepared for extraction. - or - Source was not supplied.
OperationCanceledExceptionIn .NET Framework 4.0 and above: Thrown when the compression is canceled via the provided cancellation token.
ObjectDisposedExceptionArchive has been disposed and cannot be used.

Remarks

output must be seekable.

Examples

using (FileStream lz4File = File.Open("archive.lz4", FileMode.Create))
{
    using (var archive = new Lz4Archive())
    {
        archive.SetSource("data.bin");
        archive.Save(lz4File);
     }
}

See Also


Save(FileInfo)

Saves lz4 archive to destination file provided.

public void Save(FileInfo destination)
ParameterTypeDescription
destinationFileInfoFileInfo, which will be opened as destination stream.

Exceptions

exceptioncondition
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.
InvalidOperationExceptionThe archive is prepared for extraction.
ObjectDisposedExceptionArchive has been disposed and cannot be used.

Examples

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

See Also


Save(string)

Saves archive to the destination file provided.

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

Exceptions

exceptioncondition
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.
InvalidOperationExceptionThe archive is prepared for extraction.
ObjectDisposedExceptionArchive has been disposed and cannot be used.

Examples

using (var archive = new LZ4Archive())
{
    archive.SetSource("data.bin");
    archive.Save("archive.lz4");
}

See Also