private void openFileDialog1_Click(object sender, EventArgs e) { if (openFileDialog2.ShowDialog() == DialogResult.OK) { try { string path = openFileDialog2.FileName; List <Student> studentsList = StudentsFilesUtils.ReadStudentsListFromFile(path); StudentsDGVConvert.StudentsListToDGV(grid, studentsList); MessagesUtils.ShowMessage("Данные загружены из файла"); } catch (Exception ex) { MessagesUtils.ShowError("Ошибка чтения из файла"); } } }
private void saveFileDialog1_Click(object sender, EventArgs e) { if (saveFileDialog2.ShowDialog() == DialogResult.OK) { try { string path = saveFileDialog2.FileName; List <Student> studentsList = StudentsDGVConvert.DGVToStudentsList(grid); StudentsFilesUtils.SaveStudentsListInFile(path, studentsList); MessagesUtils.ShowMessage("Данные сохранены в файл"); } catch (Exception ex) { MessagesUtils.ShowError("Ошибка сохранения в файл"); } } }