public Form1() { InitializeComponent(); // GamePath string gamePath = FileSync.GetGamePath(); if (!string.IsNullOrEmpty(gamePath)) { GameDirPath.Text = gamePath; } }
// 当文本框中的目录改变时触发 private void GameDirPath_TextChanged(object sender, EventArgs e) { string gamePath = GameDirPath.Text; if (!string.IsNullOrEmpty(gamePath) && !gamePath.EndsWith("Mount & Blade II Bannerlord") && !gamePath.Equals(FileSync.GetGamePath())) { DialogResult boxResult = MessageBox.Show("检测到您选中的路径并不是以Mount & Blade II Bannerlord结尾,您确定选择的路径正确?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (boxResult == DialogResult.Yes) { FileSync.StorageGamePath(GameDirPath.Text); } } else { FileSync.StorageGamePath(GameDirPath.Text); } }