LzipArchive.Save

Save(Stream)

Saves lzip archive to the stream provided.

public void Save(Stream outputStream)
ParameterTypeDescription
outputStreamStreamDestination stream.

Exceptions

exceptioncondition
ArgumentExceptionoutputStream does not support seeking.
ArgumentNullExceptionoutputStream is null.

Remarks

outputStream must be seekable.

Examples

using (FileStream lzFile = File.Open("archive.lz", FileMode.Create))
{
    using (var archive = new LzipArchive())
    {
        archive.SetSource("data.bin");
        archive.Save(lzFile);
     }
}

See Also


Save(string)

Saves lzip archive to 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.

Examples

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

See Also


Save(FileInfo)

Saves lzip 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.
ArgumentExceptionFile 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 LzipArchive()) 
{
    archive.SetSource(new FileInfo("data.bin"));
    archive.Save(new FileInfo("archive.lz"));
}

See Also