SetSource

LzipArchive.SetSource method (1 of 3)

Sets the content to be compressed within the archive.

public void SetSource(Stream source)
ParameterTypeDescription
sourceStreamThe input stream for the archive.

Exceptions

exceptioncondition
ArgumentExceptionThe source stream is unseekable.

Examples

using (var archive = new LzipArchive())
{
    archive.SetSource(new MemoryStream(new byte[] { 0x00, 0xFF }));
    archive.Save("archive.lz");

See Also


LzipArchive.SetSource method (2 of 3)

Sets the content to be compressed within the archive.

public void SetSource(FileInfo fileInfo)
ParameterTypeDescription
fileInfoFileInfoFileInfo which will be opened as input stream.

Exceptions

exceptioncondition
SecurityExceptionThe caller does not have the required permission to open the fileInfo.
ArgumentExceptionFile path is empty or contains only white spaces.
FileNotFoundExceptionThe file is not found.
UnauthorizedAccessExceptionPath to file is read-only or is a directory.
ArgumentNullExceptionfileInfo 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("archive.lz");
}

See Also


LzipArchive.SetSource method (3 of 3)

Sets the content to be compressed within the archive.

public void SetSource(string path)
ParameterTypeDescription
pathStringPath to file to be compressed..

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.

Examples

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

See Also