0
나는 명령 줄을 실행되는 코드의 조각을하고 아래에 몇 가지 물건을 수행프로세스가 종료되었는지 확인한 후 C# ProcessStartInfo에서 다음 명령을 실행하는 방법?
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "CMD.EXE";
System.Console.WriteLine("please insert the path of working directory");
string path = System.Console.ReadLine();
psi.WorkingDirectory = path; //@"D:\Exercises\npp52\scintilla\src";
psi.Arguments = "/C dir /s /b | cccc - --outdir=d:\\jon";
psi.WindowStyle = ProcessWindowStyle.Normal;
Process.Start(psi);
// ... cut ...
XmlTextReader reader = new XmlTextReader(@"D:\jon\anonymous.xml");
while (reader.Read())
{
switch (reader.NodeType) { /* ... */ }
}
두 번째 부분은 첫 번째 조각이 완료 될 때까지 기다린 후 시작되지 않습니다. 특히 첫 번째 조각이 anonimous.xml을 생성하기 전에 두 번째 조각이 XML을 가져 오려고합니다.
Process.Start(psi);
psi.WaitForExit(); // <-- add this
귀하의 코드가 종료 과정 기다려야합니다 :이 라인을 추가하면