How to Run External Program via a C# Program

Best Way to call external program in c# and parse output

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

Executing an external program via c# without showing the console

Try the following command line switch. It's documented here.

process.StartInfo.Arguments = "-I dummy --dummy-quiet";

Execute external program from C# code

You can use Process.Start to execute an external application.

running external C# file in a program

Check out the following article: C#: Writing extendable applications using on-the-fly compilation.



Related Topics



Leave a reply



Submit