Diagnostics.Process doesnt work with complex arguments

Hi,

I require a process to be executed like this: (this works in the commandline)

C:\7z.exe x -o"H:\download folder" "H:\download folder\*"

The result of this is the unzipping of all the zip files located in the folder named "download folder"

Now in C# I use the following statements to do it:

ProcessStartInfo startInfo = new ProcessStartInfo("C:\7z.exe");

startInfo.WindowStyle = ProcessWindowStyle.Minimized;

startInfo.Arguments ="x -o\"H:\\irf down\" \"H:\\irfa down\"\\*";

Process.Start(startInfo);

After execution however, not a single zip is extracted. so this code doesnt work, what's wrong




Answer this question

Diagnostics.Process doesnt work with complex arguments

  • HerrLinder

    Irfan Habib wrote:

    ProcessStartInfo startInfo = new ProcessStartInfo("C:\7z.exe");

    That shouldn't even compile, you need to escape the backslash in the path or use a verbatim string literal. Please post code that actually compiles.

    Irfan Habib wrote:

    startInfo.Arguments ="x -o\"H:\\irf down\" \"H:\\irfa down\"\\*";

    The end of the string should be ...\\*\"" to match what you originally posted.



  • Diagnostics.Process doesnt work with complex arguments