using System;
using System.Diagnostics;

public class RedirectingProcessOutput
{
    public static void Main()
    {
        Process p = new Process();
        p.StartInfo.FileName = "cmd.exe";
        p.StartInfo.Arguments = "/c dir *.cs";
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.RedirectStandardOutput = true;
        p.Start();
        
        string output = p.StandardOutput.ReadToEnd();
        
        Console.WriteLine("Output:");
        Console.WriteLine(output);    
    }
}

 

More Informations see this page : http://www.java2s.com/Code/CSharp/Development-Class/StartAndKillProcess.htm


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-04-24
  • 2021-09-22
  • 2021-12-24
  • 2021-09-10
  • 2021-09-20
  • 2021-09-12
猜你喜欢
  • 2022-01-10
  • 2021-09-22
  • 2021-12-06
  • 2021-09-05
  • 2021-04-28
  • 2021-06-27
  • 2021-10-08
相关资源
相似解决方案