Process.StandardOutput.ReadToEnd() : Process « System.Diagnostics « C# / C Sharp by API






Process.StandardOutput.ReadToEnd()

 



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);    
    }
}

   
  








Related examples in the same category

1.Process.CloseMainWindow
2.Process.Exited
3.Process.GetCurrentProcess()
4.Process.GetProcessById
5.Process.Kill()
6.Process.Modules
7.Process.PeakWorkingSet64
8.Process.PriorityClass
9.Process.PrivateMemorySize
10.Process.ProcessName
11.Process.Start
12.Process.StartInfo.RedirectStandardOutput
13.Process.Threads
14.Process.TotalProcessorTime
15.Process.VirtualMemorySize
16.Process.WaitForExit
17.Process.WorkingSet