private void 導入預設文件IToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ImportSettingDialog = new OpenFileDialog(); ImportSettingDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\弹幕姬\\Plugins\\"; ImportSettingDialog.FileName = "setting.xml"; ImportSettingDialog.Filter = "程式設置檔文件 (*.xml)|*.xml|所有文件 (*.*)|*.*"; ImportSettingDialog.FilterIndex = 1; ImportSettingDialog.RestoreDirectory = true; if (ImportSettingDialog.ShowDialog() == DialogResult.OK) { try { DisplaySet.Clear(); DisplaySet.ReadXml(ImportSettingDialog.FileName); dataGridView1.DataSource = DisplaySet; dataGridView1.DataMember = "event"; setting_file_path = ImportSettingDialog.FileName; } catch (Exception ex) { MessageBox.Show("讀取設置檔失敗,原始錯誤檔如下: \n" + ex.Message); } } }
private void Setting_Load(object sender, EventArgs e) { try { DisplaySet.Clear(); DisplaySet.ReadXml(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\弹幕姬\\Plugins\\setting.xml"); dataGridView1.DataSource = DisplaySet; dataGridView1.DataMember = "event"; } catch (Exception ex) { MessageBox.Show("載入預設檔失敗,請檢查插件目錄下是否存在配置文件! 詳細錯誤信息: \n" + ex.Message); } }