3
我想知道,在Visual Basic 2008中,如何执行一个外部控制台(命令行)命令并得到其输出没有中间文件的帮助(加快)?执行控制台命令,并得到它的输出
我想知道,在Visual Basic 2008中,如何执行一个外部控制台(命令行)命令并得到其输出没有中间文件的帮助(加快)?执行控制台命令,并得到它的输出
看看ProcessStartInfo.RedirectStandardOutput和Process.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()
DTB嗨, 感谢您的答复。 我认为它运作良好。唯一的是它会弹出一个命令窗口,直到外部命令结束。我怎样才能压制这个窗口?谢谢 – 2010-03-31 02:15:13
我刚刚明白了: compiler.StartInfo.CreateNoWindow = True – 2010-03-31 02:23:42