0
我有一個小窗口應用程序調用命令提示符,然後將結果分配給richTextBox。我想將命令提示符「arp -a」的結果分配給datagridview。 我該怎麼做。如何查看arp -a「ProcessStartInfo.RedirectStandardOutput」到DATAGRIDVIEW
這裏是代碼:
private void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = "/C arp -a";
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.Start();
string output = process.StandardOutput.ReadToEnd();
process.Close();
richTextBox1.Text = output;
}