Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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# 如何使用文本框值作为ping命令的参数_C#_Ping - Fatal编程技术网

C# 如何使用文本框值作为ping命令的参数

C# 如何使用文本框值作为ping命令的参数,c#,ping,C#,Ping,我可以让ping正常工作,我很难弄清楚如何将文本框的值作为参数传递,这样我就可以从文本框ping值。有人能给我指出正确的方向吗 Process test = new Process(); test.StartInfo.FileName = "ping"; test.StartInfo.UseShellExecute = false; test.StartInfo.Arguments = "www.google.com"; test.StartInfo.RedirectStandardOutput

我可以让ping正常工作,我很难弄清楚如何将文本框的值作为参数传递,这样我就可以从文本框ping值。有人能给我指出正确的方向吗

Process test = new Process();
test.StartInfo.FileName = "ping";
test.StartInfo.UseShellExecute = false;
test.StartInfo.Arguments = "www.google.com";
test.StartInfo.RedirectStandardOutput = true;
test.Start();
textBox1.Text = test.StandardOutput.ReadToEnd();

更改
test.StartInfo.Arguments=“www.google.com”
to
test.StartInfo.Arguments=textBox1.Text
,假设textBox1是您感兴趣的文本框。

谢谢,我感谢您的帮助,我将尝试一下!