Save

Bzip2Archive.Save method (1 of 2)

Saves archive to the stream provided.

public void Save(Stream outputStream, Bzip2SaveOptions saveOptions = null)
ParameterTypeDescription
outputStreamStreamDestination stream.
saveOptionsBzip2SaveOptionsOptions for saving a bzip2 archive. If not specified, 900 Kb block size would be used.

Exceptions

exceptioncondition
InvalidOperationExceptionSource of data to be archived has not been provided.
ArgumentExceptionoutputStream is not writable.
UnauthorizedAccessExceptionFile source is read-only or is a directory.
DirectoryNotFoundExceptionThe specified file source path is invalid, such as being on an unmapped drive.
IOExceptionThe File source is already open.

Remarks

outputStream must be writable.

Examples

Writes compressed data to http response stream.

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

See Also


Bzip2Archive.Save method (2 of 2)

Saves archive to destination file provided.

public void Save(string destinationFileName, Bzip2SaveOptions saveOptions = null)
ParameterTypeDescription
destinationFileNameStringThe path of the archive to be created. If the specified file name points to an existing file, it will be overwritten.
saveOptionsBzip2SaveOptionsOptions for saving a bzip2 archive. If not specified, 900 Kb block size would be used.

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

Writes compressed data to file.

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

See Also