private void OpenTaskXML(bool needDialog) { if (needDialog) { OpenFileDialog OPF = new OpenFileDialog(); OPF.InitialDirectory = Directory.GetCurrentDirectory(); OPF.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*"; //OPF.FilterIndex = 1; //OPF.RestoreDirectory = true; if (OPF.ShowDialog() == DialogResult.OK) { gTaskConfig_path = OPF.FileName; } } if (File.Exists(gTaskConfig_path)) { try { metroGrid10.Rows.Clear(); metroTextBox1.Lines = File.ReadAllLines(gTaskConfig_path); metroTextBox5.Text = gTaskConfig_path; TaskConf conf = new TaskConf(); conf.Name = Path.GetFileName(gTaskConfig_path); conf.Comment = TaskConf.XMLConfiguration; AddConfig(conf, gTaskConfig_path); for (int i = 0; i < conf.GetItems().Count; i++) { metroGrid10.Rows.Add(conf.GetItems()[i].Name, conf.GetItems()[i].Value); } } catch { MetroFramework.MetroMessageBox.Show(this, "Некорректный XML файл.", "Оповещение", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MetroFramework.MetroMessageBox.Show(this, "XML файл не найден.", "Оповещение", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (metroTextBox5.Text != "") { metroButton8.Enabled = true; metroButton9.Enabled = true; } }