Launching a process and displaying its standard output - The Code Project - C# Programming. So, here's how to do Perl's '$str = `shellcommand`' in C#:
public string Run(string command, string args){
Process p = new Process(); // System.Diagnostics.Process
p.EnableRaisingEvents = false;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.FileName = command;
p.StartInfo.Arguments = args;
p.Start();
return p.StandardOutput.ReadToEnd();
}
Feel free to post a comment below. Please see my comment policy.
Formatting Rules (No HTML):