SevenZipArchive.CreateEntries

CreateEntries(DirectoryInfo, bool)

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

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

Return Value

The archive with entries composed.

Exceptions

exceptioncondition
DirectoryNotFoundExceptionThe path to directory is invalid, such as being on an unmapped drive.
SecurityExceptionThe caller does not have the required permission to access directory.

Examples

using (SevenZipArchive archive = new SevenZipArchive())
{
    DirectoryInfo folder = new DirectoryInfo("C:\folder");
    archive.CreateEntries(folder);
    archive.Save("folder.7z");
}

See Also


CreateEntries(string, bool)

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

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

Return Value

The archive with entries composed.

Examples

Compose 7z archive with LZMA2 compression.

using (SevenZipArchive archive = new SevenZipArchive(new SevenZipEntrySettings(new SevenZipLZMACompressionSettings())))
{
    archive.CreateEntries("C:\folder");
    archive.Save("folder.7z");
}

See Also