Skip to content

Commit

Permalink
rename folder error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
setsumi committed Jul 5, 2023
1 parent 2f6b7a1 commit 5eff964
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/syosetuDownloader/HistoryWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5eff964

Please sign in to comment.