Bzip2Archive.SetSource

SetSource(Stream)

Sets the content to be compressed within the archive.

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

Examples

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

See Also


SetSource(FileInfo)

Sets the content to be compressed within the archive.

public void SetSource(FileInfo fileInfo)
ParameterTypeDescription
fileInfoFileInfoThe reference to a file to be compressed.

Examples

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

See Also


SetSource(string)

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 (Bzip2Archive archive = new Bzip2Archive()) 
{
    archive.SetSource("data.bin");
    archive.Save("archive.bz2");
}

See Also


SetSource(TarArchive, TarFormat)

Sets the content to be compressed within the archive.

public void SetSource(TarArchive tarArchive, TarFormat format = TarFormat.UsTar)
ParameterTypeDescription
tarArchiveTarArchiveTar archive to be compressed.
formatTarFormatDefines tar header format.

Remarks

Use this method to compose joint tar.bz2 archive.

Examples

using (var tarArchive = new TarArchive())
{
    tarArchive.CreateEntry("first.bin", "data1.bin");
    tarArchive.CreateEntry("second.bin", "data2.bin");
    using (var bzippedArchive = new Bzip2Archive())
    {
        bzippedArchive.SetSource(tarArchive);
        bzippedArchive.Save("archive.tar.bz2");
    }
}

See Also


SetSource(CpioArchive, CpioFormat)

Sets the content to be compressed within the archive.

public void SetSource(CpioArchive cpioArchive, CpioFormat format = CpioFormat.OldAscii)
ParameterTypeDescription
cpioArchiveCpioArchiveCpio archive to be compressed.
formatCpioFormatDefines cpio header format.

Remarks

Use this method to compose joint cpio.bz2 archive.

Examples

using (var cpioArchive = new CpioArchive())
{
    cpioArchive.CreateEntry("first.bin", "data1.bin");
    cpioArchive.CreateEntry("second.bin", "data2.bin");
    using (var bzippedArchive = new Bzip2Archive())
    {
        bzippedArchive.SetSource(cpioArchive);
        bzippedArchive.Save("archive.cpio.bz2");
    }
}

See Also