Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用参数启动流程_C#_Parameters_Process - Fatal编程技术网

C# 使用参数启动流程

C# 使用参数启动流程,c#,parameters,process,C#,Parameters,Process,我正在尝试为samp(Gta San Andreas Multiplayer)编写一个客户端,该客户端将自动设置为用户名和连接服务器 Samp有自己的参数用于设置用户名、服务器ip、服务器端口等 我的问题是我的过程只需要第一个参数。我需要使用2个参数 我在谷歌上搜索了一下,找到了一些东西,但他们大多使用cmd,参数类型和我的不匹配。我尝试了几种方法来解决我的问题,但失败了 这是我的密码 islem.StartInfo.FileName = yol + "\\" +

我正在尝试为samp(Gta San Andreas Multiplayer)编写一个客户端,该客户端将自动设置为用户名和连接服务器

Samp有自己的参数用于设置用户名、服务器ip、服务器端口等

我的问题是我的过程只需要第一个参数。我需要使用2个参数

我在谷歌上搜索了一下,找到了一些东西,但他们大多使用cmd,参数类型和我的不匹配。我尝试了几种方法来解决我的问题,但失败了

这是我的密码

                islem.StartInfo.FileName = yol + "\\" + "samp.exe";
                string parametre = " -c -h192.168.1.2 -n"+textBox1.Text+"";

                islem.StartInfo.Arguments = string.Format(parametre);
                islem.Start();
请尝试以下方法:

ProcessStartInfo startInfo = new ProcessStartInfo(yol + "\\" + "samp.exe");
startInfo.Arguments = "-c -h192.168.1.2 -n" + textBox1.Text;
Process.Start(startInfo);

还应使用
Path.Combine()
而不是硬编码的
“\\\”
分隔符。仍然可以获得正确的IP地址