一个C#中调用命令行程序的问题

现在我有一个C#写的界面程序,我希望在这个程序中调用一个另外
一个命令行程序,并且获取这个命令行程序的输出,然后显示在C#
界面程序的TextBox里,我应该如何做呢?

如果要调用的是java的.jar程序,是不是实现方式又有不同?请大虾
们指教!
---------------------------------------------------------------

System.Diagnostics.ProcessStartInfo ps = new ProcessStartInfo( "Ping.exe" , "127.0.0.1" );
ps.UseShellExecute = false;
ps.CreateNoWindow = true;//加这一句
ps.RedirectStandardOutput = true;
Process p= Process.Start(ps);
p.WaitForExit();
string output = p.StandardOutput.ReadToEnd();
this.textBox1.Text = output;

Published At
Categories with Web编程
Tagged with
comments powered by Disqus