I’ve been attempting to launch a zip utility from C#.NET code. Unfortunately, the 7-Zip utility that I’m using doesn’t like the command line string that I’m passing in. Without getting into the switch syntax for this utility, I can tell you that the command line in the code below works when the utility is launched from the command prompt, so no problem there.
Here’s the sample code:
private void btnZipMe_Click(object sender, System.EventArgs e)
string strCmdLine = @"7z a -tzip c:\backups\schoolname.zip \a\*.doc";
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = @"C:\Program Files\7-Zip\7zG.exe";
psi.Arguments = strCmdLine;
Process p = Process.Start(psi);
When the last line of code above executes, the external utility pops up a message box stating “Incorrect command line” . Additionally, just as a test, I also set up everything under my C: drive to avoid escape characters even though the literal symbol should handle that – same error. Any ideas?