From 5eff96409f60397752e20dfe7b1508a21b2bd8b1 Mon Sep 17 00:00:00 2001 From: setsumi Date: Wed, 5 Jul 2023 17:56:15 +1000 Subject: [PATCH] rename folder error handling --- src/syosetuDownloader/HistoryWindow.xaml.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/syosetuDownloader/HistoryWindow.xaml.cs b/src/syosetuDownloader/HistoryWindow.xaml.cs index 0b65068..8b056cb 100644 --- a/src/syosetuDownloader/HistoryWindow.xaml.cs +++ b/src/syosetuDownloader/HistoryWindow.xaml.cs @@ -171,12 +171,20 @@ private void RenameCommand_Executed(object sender, ExecutedRoutedEventArgs e) form.ValidateInput(); if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { - item.Title = form.textBox2.Text; - Syousetsu.History.SaveItem(item); - + bool error = false; if (Directory.Exists(form.CurrNovelFolder)) { - Directory.Move(form.CurrNovelFolder, form.textBox3.Text); + try { Directory.Move(form.CurrNovelFolder, form.textBox3.Text); } + catch (Exception ex) + { + error = true; + MessageBox.Show(ex.Message, "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); + } + } + if (!error) + { + item.Title = form.textBox2.Text; + Syousetsu.History.SaveItem(item); } ICollectionView view = CollectionViewSource.GetDefaultView(viewHistoryList.ItemsSource);