怎么在c#中调用外部命令行程序及获取它的输出 在c#中怎么调用一个命令行程序,这个命令行程序有一些输出,类似于“正在。”,我如何获得这些信息呢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 输出重定向比如:运行cmd.exe,输入 ping www.csdn.net >>c:\pinglog.txt这样输出就被定向到c:\pinglog.txt,读取这个文件即可 或者启动process,然后读取StandardOutputProcess myProcess = new Process();ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("Process_StandardOutput_Sample.exe" );myProcessStartInfo.UseShellExecute = false;myProcessStartInfo.RedirectStandardOutput = true;myProcess.StartInfo = myProcessStartInfo;myProcess.Start();StreamReader myStreamReader = myProcess.StandardOutput;// Read the standard output of the spawned process.string myString = myStreamReader.ReadLine();Console.WriteLine(myString);myProcess.Close(); 参考这里http://blog.csdn.net/zhzuo/archive/2004/03/21/22024.aspx 怎样获取listbox数据源的隐藏信息? 请问一下加载程序集的问题 C# RegEnumValue的声明、用法 水晶报表求教 (急切求助)如何用SOCKET方式读写数据库(在线等) 反编译出来的代码有点问题,请帮我看下,非常感谢 请教一个重画显示背景图片的问题 C# 怎么做购物车 vs2005 调试:源文件与模块生成时的文件不同。仍要让调试器使用它 向sortedList对象中添加值时,以字符(串)为key,怎么控制排列顺序? Datagrid多行计算(在库数量-申请数量=当前库存),加急,在线等!!!! 问一个绘图的问题
比如:运行cmd.exe,输入 ping www.csdn.net >>c:\pinglog.txt这样输出就被定向到c:\pinglog.txt,读取这个文件即可
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("Process_StandardOutput_Sample.exe" );
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();StreamReader myStreamReader = myProcess.StandardOutput;
// Read the standard output of the spawned process.
string myString = myStreamReader.ReadLine();
Console.WriteLine(myString);
myProcess.Close();
http://blog.csdn.net/zhzuo/archive/2004/03/21/22024.aspx