2010-03-29 107 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