我目前正在调用一个从文本文件输入参数的进程,
虽然读取文本文件的一行时它可以正常工作,但文本文件的第二行直接执行.有没有办法告诉Process.Start等到上一个命令完成?
static void Main(string[] args)
{
foreach (string exename in System.IO.File.ReadAllLines("test.txt"))
{
Process.Start("test.exe", "\"" + exename + "\"");
}
}
Run Code Online (Sandbox Code Playgroud)
static void Main(string[] args)
{
foreach (string exename in System.IO.File.ReadAllLines("test.txt"))
{
Process.Start("test.exe", "\"" + exename + "\"").WaitForExit();
}
}
Run Code Online (Sandbox Code Playgroud)
在MSDN上记录.我通常谷歌" MSDN [class/method/property]".在这种情况下,您可以使用Google搜索" msdn process class",然后您就可以找到该方法.
| 归档时间: |
|
| 查看次数: |
1497 次 |
| 最近记录: |