H开发者_StackOverflow中文版ow to call an exe, generated from one c# file, from another c# file?
using System.Diagnostics;
string command = @"C:\tmp\myExe.exe -my -params";
ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " + command)
{
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};
using (Process proc = new Process())
{
proc.StartInfo = procStartInfo;
proc.Start();
return proc.StandardOutput.ReadToEnd();
}
System.Diagnostics.Process.Start("Path to any file, including exes");
If you want to generate the C# file before executing it you can use the CSharpCodeProvider to compile the C# file, and then use the Process class to execute the output file.
You can find examples of each in the provided links.
精彩评论