Reputation: 433
I am trying to zip directory with 7zip but it not works, and neither gives error/exception
Code
string sourceCompressDir = @"c:\7ziptest\TestFolder";
string targetCompressName = @"c:\7ziptest\TestFolder.zip";
ProcessStartInfo pCompress = new ProcessStartInfo();
pCompress.FileName = "7za.exe";
//Not working for below arguments
pCompress.Arguments = "7z a " + targetCompressName + " " + sourceCompressDir";
pCompress.WindowStyle = ProcessWindowStyle.Hidden;
pCompress.UseShellExecute = false;
Process x = Process.Start(pCompress);
x.WaitForExit();
Could anyone guide me? I am following link http://www.dotnetperls.com/7-zip AND COMMAND LIST FOR 7ZIP
I have tried directly with command prompt but none command works for me !
1) C:>c:\7ziptest/7za.exe 7z a -tzip "c:\7ziptest\TestFolder.zip" "c:\7ziptest\tes tfolder"
7-Zip (A) 4.42 Copyright (c) 1999-2006 Igor Pavlov 2006-05-14
Error:
Incorrect command line
2) C:>c:\7ziptest/7za.exe 7z a -tzip "c:\7ziptest\TestFolder.zip" "c:\7ziptest\tes tfolder\"
7-Zip (A) 4.42 Copyright (c) 1999-2006 Igor Pavlov 2006-05-14
Error:
Incorrect command line
3) C:>c:\7ziptest/7za.exe 7z a -tzip "c:\7ziptest\TestFolder.zip" "c:\7ziptest\tes tfolder\" -mx=9
7-Zip (A) 4.42 Copyright (c) 1999-2006 Igor Pavlov 2006-05-14
Error:
Incorrect command line
Could anyone help me to find what is wrong in above commands !!!
Upvotes: 2
Views: 1815
Reputation: 5954
D:\>7za a -tzip arch.zip "D:\dirName"
This works for me.
So the equivalent arguments in C# code should be:
pCompress.Arguments = "a -tzip \"" + targetCompressName + "\" \"" + sourceCompressDir +"\"";
Upvotes: 2