This example demonstrates how, from C#, run a program / external application and read the output or results of this program.
The code below triggers the Windows command prompt (cmd.exe
) and passes to it the command that must be executed (in this case, the command dir
).
On the estate Arguments
you can replace the command say by the application of your interest (Gfix with their respective parameters).
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();
p.WaitForExit();
Console.WriteLine("Output:");
Console.WriteLine(output);
}
}
This code was copied from ONLY in English.