CreateEntries

CpioArchive.CreateEntries method (1 of 2)

Adds to the archive all the files and directories recursively in the directory given.

public CpioArchive CreateEntries(string sourceDirectory, bool includeRootDirectory = true)
ParameterTypeDescription
sourceDirectoryStringDirectory to compress.
includeRootDirectoryBooleanIndicates whether to include the root directory itself or not.

Return Value

Cpio entry instance.

Exceptions

exceptioncondition
ArgumentNullExceptionsourceDirectory is null.
SecurityExceptionThe caller does not have the required permission to access sourceDirectory.
ArgumentExceptionsourceDirectory contains invalid characters such as “, <, >, or |.
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. The specified path, file name, or both are too long.
IOExceptionsourceDirectory stands for a file, not for a directory.

Examples

using (FileStream cpioFile = File.Open("archive.cpio", FileMode.Create))
{
    using (var archive = new CpioArchive())
    {
        archive.CreateEntries("C:\folder", false);
        archive.Save(cpioFile);
    }
}

See Also


CpioArchive.CreateEntries method (2 of 2)

Adds to the archive all the files and directories recursively in the directory given.

public CpioArchive CreateEntries(DirectoryInfo directory, bool includeRootDirectory = true)
ParameterTypeDescription
directoryDirectoryInfoDirectory to compress.
includeRootDirectoryBooleanIndicates whether to include the root directory itself or not.

Return Value

Cpio entry instance.

Exceptions

exceptioncondition
ArgumentNullExceptiondirectory is null.
SecurityExceptionThe caller does not have the required permission to access directory.
IOExceptiondirectory stands for a file, not for a directory.

Examples

using (FileStream cpioFile = File.Open("archive.cpio", FileMode.Create))
{
    using (var archive = new CpioArchive())
    {
        archive.CreateEntries(new DirectoryInfo("C:\folder"), false);
        archive.Save(cpioFile);
    }
}

See Also