Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void saveButton_Click(object sender, EventArgs e)
- {
- if (saveFileDialog1.ShowDialog() == DialogResult.OK)
- {
- pathToSave = saveFileDialog1.FileName;
- FileInfo newFile = new FileInfo(pathToSave);
- if (newFile.Exists)
- {
- if (MessageBox.Show("Файл с таким именем уже существует. Хотите перезаписать?", "Сообщение", MessageBoxButtons.YesNo)
- == DialogResult.Yes)
- {
- try
- {
- SaveFile.SaveThisInFile(pathToSave, allWeHave);
- }
- catch (Exception)
- {
- MessageBox.Show("Что-то пошло не так");
- }
- }
- } else
- {
- File.Create(pathToSave);
- try
- {
- SaveFile.SaveThisInFile(pathToSave, allWeHave);
- }
- catch (Exception)
- {
- MessageBox.Show(pathToSave);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement