【发布时间】:2013-07-25 12:43:38
【问题描述】:
当程序加载时我想检查一个文件,如果文件存在我想继续,如果不存在我不希望它打开主窗体并打开一个窗体 2。
这是我目前所拥有的:
private void Home_Load(object sender, EventArgs e)
{
string path = @"c:\Path\Path2\file.txt";
if (!File.Exists(path))
{
MessageBox.Show("File not found!");
form2 f = new form2();
f.Show();
this.Hide();
}
else
{
MessageBox.Show("File found!");
}
}
但它打开了两种形式。谁能帮帮我吗?谢谢。
【问题讨论】: