[Mono-list] How to start a non mono program
Marcus
mathpup@mylinuxisp.com
Wed, 22 Dec 2004 14:08:07 -0600
Use System.Diagnostics.Process.Start(). You will most likely want to use one
of the variations that uses an instance of ProcessStartInfo. Here's one
example:
/*! Invokes the C++ compiler to compile the given file. The
output filename is specified as objectFile. Additional compiler
options can be given using the compilerOptions parameter.
*/
public bool CompileCPPFile(string sourceFile, string objectFile, string
compilerOptions)
{
string totalCompilerOptions;
if (compilerOptions == null)
totalCompilerOptions = String.Format("-o {1} {0} {2}", sourceFile,
objectFile);
else
totalCompilerOptions = String.Format("-o {1} {0} {2}", sourceFile,
objectFile, compilerOptions);
ProcessStartInfo startInfo = new ProcessStartInfo(
"g++", totalCompilerOptions);
Debug.WriteLine("Starting C++ compiler: " + startInfo.FileName + " " +
startInfo.Arguments);
startInfo.UseShellExecute = false;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
Process compiler = Process.Start(startInfo);
compiler.StandardError.ReadToEnd();
compiler.StandardOutput.ReadToEnd();
compiler.WaitForExit();
Debug.WriteLine(
String.Format("C++ compiler returns {0}", compiler.ExitCode) );
return compiler.ExitCode == 0? true : false;
}
On Wednesday 22 December 2004 11:38 am, Andreas Sliwka wrote:
> Greetings,
> how would I start another program from within a mono program? I'm
> also interested in catching the programs output, but its secondary.