C#Explicity在Process.Start()上抛出错误

时间:2013-01-31 22:42:45

标签: c#

我是一个C#初学者,我为游戏做了一个小启动器并启动它,我正在使用这个按钮事件:

private void button5_MouseClick(object sender, MouseEventArgs e)
    {
        Process.Start("engine.exe", "/load /config debug");
        Application.Exit();
    }

正如您所看到的,这也会在游戏开始时使用Application.Exit()来关闭启动器,因为它们是分开的。

我想知道的是,我的方法是否适合启动游戏+关闭启动器,还有,

我想知道当我点击按钮并且缺少engine.exe时如何发出弹出消息“未找到Engine.exe”。

谢谢!

1 个答案:

答案 0 :(得分:4)

try
{
    Process.Start("engine.exe", "/load /config debug");
    Application.Exit();    
}
catch(FileNotFoundException e)
{
   MessageBox.Show(e.Message);
}