I am trying to zip some folders. They have different paths, will not belong to the same directory.
I tested the command line arguments that I would give, and it works, but I can't get it to work from c#:
string destination = "some path\\name.7z";
string pathToZip = "path to zip\\7z.exe"; // or 7za.exe
ProcessStartInfo p = new ProcessStartInfo();
p.FileName = pathToZip;
p.Arguments = "a \"" + destination + "\" \"";
// room for the foreach - but even one directory doesn't work right now
p.Arguments += directoryPath + "\" \"";
p.Arguments += "\" -mx=9 -aoa";
Process x = Process.Start(p);
With 7z.exe i get a blink; With 7za.exe, I get the typical command-line zip sequence, with files zipping through, adding to archive, and an archive gets created.
Then I go to it and right-click, open or double-click... and I get that it is an invalid archive (Can not open file "name.7z" as an archive
). Try command line, with 7za, to extract - same thing.
Edit: I found the solution:
My problem was the -aoa option (which I used for overwrite) - after removing it, it worked.