try { OpenFileDialog openFileDialog = new OpenFileDialog(); string str = comboBox_hexFilePath.Text; string file = str.Substring(0, str.LastIndexOf("\") + 1);//去掉了路径 openFileDialog.InitialDirectory = file; openFileDialog.Filter = "Hex文件|*.hex"; openFileDialog.RestoreDirectory = true; openFileDialog.FilterIndex = 1; comboBox_hexFilePath.Text = openFileDialog.FileName;//文件名 } } catch { show_info("hex文件选择.."); }