开发者

How to pass multiple arguments to a newly created process in C# .net?

开发者 https://www.devze.com 2023-01-11 00:17 出处:网络
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 m

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" );
0

精彩评论

暂无评论...
验证码 换一张
取 消