【问题标题】:c# execute shell command and get result [duplicate]c#执行shell命令并得到结果[重复]
【发布时间】:2013-03-27 02:33:09
【问题描述】:

我正在执行如下命令提示符命令:

string cmd = "/c dir" ; 
System.Diagnostics.Process proc = new System.Diagnostics.Process(); 
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.Arguments = cmd; 
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true; 
proc.Start();

如何获取命令的输出?

【问题讨论】:

    标签: c# shell command output prompt


    【解决方案1】:

    试试这个

    string output = proc.StandardOutput.ReadToEnd();
    

    【讨论】:

      猜你喜欢
      • 2015-07-06
      • 2016-03-21
      • 1970-01-01
      • 1970-01-01
      • 2013-08-15
      • 1970-01-01
      • 2015-10-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多