From a32a58f26dd8b27743291d014fb2a1c91f8ff7bf Mon Sep 17 00:00:00 2001 From: gabrielpatzleiner Date: Thu, 10 Apr 2014 17:02:50 +0200 Subject: [PATCH] Updated Delete Mod so it shows a Message when it cannot access the file, closes #59 --- MinecraftLauncher/MainWindow.xaml.vb | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/MinecraftLauncher/MainWindow.xaml.vb b/MinecraftLauncher/MainWindow.xaml.vb index b419f87..4c9ad34 100644 --- a/MinecraftLauncher/MainWindow.xaml.vb +++ b/MinecraftLauncher/MainWindow.xaml.vb @@ -1449,17 +1449,26 @@ Public Class MainWindow Dim Version As String = DirectCast(lb_mods.SelectedItem, Modifications.Mod).versions.Where(Function(p) p.version = cb_modversions.SelectedItem.ToString).First.version Delete_Mod(Version) End Sub - Public Sub Delete_Mod(Version As String) + Public Async Function Delete_Mod(Version As String) As Task + Dim capturedException As ExceptionDispatchInfo = Nothing For Each selectedmod As Modifications.Mod In lb_mods.SelectedItems - Dim Struktur As String = Version & "\" & Version & "-" & selectedmod.id & "." & selectedmod.extension - If File.Exists(tb_modsfolder.Text & "\" & Struktur) = True Then - File.Delete(tb_modsfolder.Text & "\" & Struktur) + Try + Dim Struktur As String = Version & "\" & Version & "-" & selectedmod.id & "." & selectedmod.extension + If File.Exists(tb_modsfolder.Text & "\" & Struktur) = True Then + File.Delete(tb_modsfolder.Text & "\" & Struktur) + End If + Catch ex As Exception + capturedException = ExceptionDispatchInfo.Capture(ex) + End Try + If capturedException IsNot Nothing Then + Await Me.ShowMessageAsync("Fehler", "Mod konnte nicht gelöscht werden: " & selectedmod.name & Environment.NewLine & "Falls der Mod in Minecraft geöffnet ist, schließe Minecraft zuerst!") End If Next Dim selected As Integer = lb_mods.SelectedIndex Filter_Mods() lb_mods.SelectedIndex = selected - End Sub + + End Function Private Async Sub btn_downloadmod_Click(sender As Object, e As RoutedEventArgs) Handles btn_downloadmod.Click If moddownloading = True Then Await Me.ShowMessageAsync("Download läuft", "Eine Mod wird bereits heruntergeladen. Warte bitte, bis diese fertig ist!", MessageDialogStyle.Affirmative, New MetroDialogSettings() With {.AffirmativeButtonText = "Ok", .ColorScheme = MetroDialogColorScheme.Accented})