2010-03-29 102 views

回答

5

看看ProcessStartInfo.RedirectStandardOutputProcess.StandardOutput

例子:

compiler.StartInfo.FileName = "csc.exe" 
compiler.StartInfo.Arguments = "/r:System.dll /out:sample.exe stdstr.cs" 
compiler.StartInfo.UseShellExecute = False 
compiler.StartInfo.RedirectStandardOutput = True 
compiler.Start() 

Console.WriteLine(compiler.StandardOutput.ReadToEnd()) 

compiler.WaitForExit() 
+0

DTB嗨, 感谢您的答复。 我认为它运作良好。唯一的是它会弹出一个命令窗口,直到外部命令结束。我怎样才能压制这个窗口?谢谢 – 2010-03-31 02:15:13

+1

我刚刚明白了: compiler.StartInfo.CreateNoWindow = True – 2010-03-31 02:23:42