c# execute shell command and get result

c#, command, output, prompt, shell

Solution

try this

string output = proc.StandardOutput.ReadToEnd();

Problem

I am executing a command prompt command as follows: ``` 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(); ``` How to I get the output of the command?

Original source

Related problems