0

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!

Tomek
  • 701
  • 2
  • 8
  • 20

1 Answers1

0

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

HeadJ.E.M.
  • 101
  • 8
  • Well your answer wasn't something new for me (check commented code of mine), but I re-checked the code and seems I know why it was zipping zipped folder back than. Nevertheless, thanks! – Tomek Oct 08 '15 at 13:38
  • Its a pleasure also might be helpful to check out the Ionic.Zip library i use it myself and is quite simple – HeadJ.E.M. Oct 08 '15 at 16:46