How to pass multiple arguments to a newly created process in C# .net?
How can I pass multiple arguments to a newly created process in C#?
Also which class (Process
or ProcessStartInfo
or MyProcess
) in should I use in executing a program, with the condition of passing multiple arguments to the newly created/executed process?
As开发者_如何学C is I have the equivalent (Borland) C++ code for the same task, which is as follows:
spawnv(P_NOWAITO,Registry->ReadString("Downloader").c_str(),arglist);
where arglist
is a char pointer array and
Registry->ReadString("Downloader").c_str()
, is the program to execute.
In order to pass multiple command line arguments you should separate each with a space and surround it in quotes in case the argument itself contains a space.
string[] args = { "first", "second", "\"third arg\"" };
Process.Start("blah.exe", String.Join(" ", args));
Process.Start( "program.exe", "arg1 arg2 arg3" );
精彩评论