SevenZipSharp
SevenZipSharp copied to clipboard
How to append files to a splitted archive?
When I use this code it works fine:
string ArchiveFile = Path.Combine(Environment.CurrentDirectory, "Archive.7z");
SevenZipCompressor.SetLibraryPath(Path.Combine(Environment.CurrentDirectory, "7z.dll"));
var compressor = new SevenZipCompressor
{
ArchiveFormat = OutArchiveFormat.SevenZip,
DirectoryStructure = true,
PreserveDirectoryRoot = true
// , VolumeSize = 1000 * 1024 * 10 // 10MB segments
};
// Compress the Files directory
compressor.CompressDirectory(Path.Combine(Environment.CurrentDirectory, "Files"), ArchiveFile);
// Append two files
var modificationList = new List<string>
{
Path.Combine(Environment.CurrentDirectory, "EventLog.txt"),
Path.Combine(Environment.CurrentDirectory, "FileVersions.txt")
};
compressor.CompressionMode = CompressionMode.Append;
compressor.DirectoryStructure = false;
compressor.PreserveDirectoryRoot = false;
compressor.CompressFiles(ArchiveFile, modificationList.ToArray());
but when I want to get a splitted archive (uncomment the line with VolumeSize) I got a Exception:
Could not pack files! Message: file "...\Archive.7z" does not exist.
What do I have to do to make it work?