现象 中文模式下打开了选文件的对话框,直接卡死选不了文件。ShowDialog接口有bug
public string OpenProject()
{
OpenFileDialog openFileDialog1 = new OpenFileDialog
{
Title = 'open',
Filter = ".stil file|*.stil"
};
openFileDialogResult = DialogResult.No;
Thread invokeThread = new Thread(new ThreadStart(() => InvokeMethod(openFileDialog1)));
invokeThread.SetApartmentState(ApartmentState.STA);
invokeThread.Start();
invokeThread.Join();
DialogResult dr = openFileDialogResult;
if (dr != DialogResult.OK)
{ return null; }
string filePath = openFileDialog1.FileName;
return filePath;
}
private DialogResult openFileDialogResult;
private void InvokeMethod(OpenFileDialog openFileDialog)
{
openFileDialogResult = openFileDialog.ShowDialog();
}