【发布时间】:2017-07-22 09:57:25
【问题描述】:
我正在使用代码解析器CTAG,它一次解析一个文件并在文本文件中报告结果。我有一个文件列表,我使用以下代码解析和处理它们的输出。
string folder = "C:\\Temp\\";
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = folder + "command.bat";
foreach (string file in files)
{
string command = @"ctags -R --c++-kinds=+p --fields=+iaS --extra=+q " + file;
File.WriteAllText(folder + "command.bat", "cd " + folder + Environment.NewLine + command);
p.Start();
p.WaitForExit();
string[] str = File.ReadAllLines(folder + "tags");
ProcessParsedCode(str);
}
上面的代码不断打开和关闭一个新窗口来解析每个看起来很难看的文件,因为我有超过 100 个文件。我想在一个命令窗口中执行此操作。
【问题讨论】:
-
您是否尝试将
WindowStyle设置为Hidden? -p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; -
用
p.StartInfo.CreateNoWindow = true;隐藏命令窗口怎么样? -
更改 WindowStyle 没有帮助,CreateNoWindow 有。谢谢@Rawns。
-
没问题,我已将其添加为答案,因为它有帮助。 :)
标签: c# command-line console-application ctags