ale*_*ale 72 c# console console-application
当用户选择菜单选项时,我需要关闭控制台.
我尝试使用,close()但它没有工作..
我怎样才能做到这一点?
Pri*_*ank 153
Environment.Exit 和 Application.Exit
Environment.Exit(0) 更清洁.
http://geekswithblogs.net/mtreadwell/archive/2004/06/06/6123.aspx
Rob*_*ard 25
关闭,您是否希望关闭控制台应用程序的当前实例,或者您希望应用程序进程终止?错过了所有重要的退出代码:
Environment.Exit(0);
或者关闭表单的当前实例:
this.Close();
有用的链接.
小智 5
 //How to start another application from the current application
 Process runProg = new Process();
 runProg.StartInfo.FileName = pathToFile; //the path of the application
 runProg.StartInfo.Arguments = genArgs; //any arguments you want to pass
 runProg.StartInfo.CreateNoWindow = true;
 runProg.Start();
 //How to end the same application from the current application
 int IDstring = System.Convert.ToInt32(runProg.Id.ToString());
 Process tempProc = Process.GetProcessById(IDstring);
 tempProc.CloseMainWindow();
 tempProc.WaitForExit();