CreateEntries

SevenZipArchive.CreateEntries method (1 of 2)

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

public SevenZipArchive CreateEntries(DirectoryInfo directory, bool includeRootDirectory = true)
Parameter Type Description
directory DirectoryInfo Directory to compress.
includeRootDirectory Boolean Indicates whether to include the root directory itself or not.

Return Value

The archive with entries composed.

Exceptions

exception condition
DirectoryNotFoundException The path to directory is invalid, such as being on an unmapped drive.
SecurityException The 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


SevenZipArchive.CreateEntries method (2 of 2)

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

public SevenZipArchive CreateEntries(string sourceDirectory, bool includeRootDirectory = true)
Parameter Type Description
sourceDirectory String Directory to compress.
includeRootDirectory Boolean Indicates 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