Reputation: 741
at the begging I would like to make a point what is my target - to create split (non)compressed archive with keeping structure of catalog intact.
I checked few libraries, but SevenZipSharp seems to be closest my way of doing that.
Right now I have a code like this:
public static void PackFiles()
{
string dll = @"C:\Users\MyUsername\Downloads\7zip32b\7z.dll";
SevenZipCompressor.SetLibraryPath(dll);
SevenZipCompressor compressor = new SevenZipCompressor();
compressor.ArchiveFormat = OutArchiveFormat.SevenZip;
compressor.CompressionMode = CompressionMode.Create;
compressor.TempFolderPath = System.IO.Path.GetTempPath();
compressor.VolumeSize = 1 * 1024 * 1024;
//compressor.CompressDirectory(defaultContentFolder, (defaultReadyZipFolder + zipName + ".zip"));
// THIS ONE IS WORKING, BUT PACKS WHOLE FOLDER INSIDE ARCHIVE..
string[] files = Directory.GetFiles(defaultContentFolder,"*.*",SearchOption.AllDirectories);
compressor.CompressFiles(@"C:\Users\MyUsername\Packed\ArchiveName", files);
Console.WriteLine("Zipped!");
}
So, as I commented above. When using compressor.CompressDirectory
I managed to zip whole folder which then was packed inside another archive which get split. Not pretty at all...
So I thought about giving him list of files inside dir to pack them as one archive, but it is not working.
When I debug, compiler just executes CompressFiles
method, but does not enter other parts of code at all, like it was skipped or something... files parameter indeed consists off array of files paths, so that part is ok?
Any ideas what's going on there? Or maybe different solutions to check?
Thanks in advance!
Upvotes: 0
Views: 699
Reputation: 101
Dont know if this helps but after doing some digging i found this little article here
http://www.cupofdev.com/compress-files-7zip-csharp/
sevenZipCompressor.CompressDirectory();
might be something to try is the compress directory should compress your directory instead of splitting the files
Upvotes: 0