diff options
Diffstat (limited to 'MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs')
| -rw-r--r-- | MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs | 54 |
1 files changed, 45 insertions, 9 deletions
diff --git a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs index bdf34b956..7f82d1840 100644 --- a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs +++ b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs @@ -62,21 +62,57 @@ namespace MediaBrowser.Uninstaller.Execute private void btnUninstall_Click(object sender, RoutedEventArgs e) { // First remove our shortcuts - var startMenu = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Media Browser"); + lblHeading.Content = "Removing Shortcuts..."; + btnCancel.IsEnabled = btnUninstall.IsEnabled = false; + grdOptions.Visibility = Visibility.Hidden; + + var startMenu = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Media Browser 3"); var linkName = "Media Browser " + Product + ".lnk"; - try + RemoveShortcut(Path.Combine(startMenu, linkName)); + linkName = "Uninstall " + linkName; + RemoveShortcut(Path.Combine(startMenu, linkName)); + if (Product == "Server") { - File.Delete(Path.Combine(startMenu,linkName)); + RemoveShortcut(Path.Combine(startMenu, "Dashboard.lnk")); } - catch {} // oh well - - linkName = "Uninstall " + linkName; - try + // if the startmenu item is empty now - delete it too + if (Directory.GetFiles(startMenu).Length == 0) { - File.Delete(Path.Combine(startMenu,linkName)); + try + { + Directory.Delete(startMenu); + } + catch (DirectoryNotFoundException) + { + } + catch (Exception ex) + { + { + MessageBox.Show(string.Format("Error attempting to remove shortcut folder {0}\n\n {1}", startMenu, ex.Message), "Error"); + } + } } - catch {} // oh well + + // and done + lblHeading.Content = string.Format("Media Browser {0} Uninstalled.", Product); + btnUninstall.Content = "Finish"; + } + + private static void RemoveShortcut(string path) + { + try + { + File.Delete(path); + } + catch (FileNotFoundException) + { + } // we're trying to get rid of it anyway + catch (Exception ex) + { + MessageBox.Show(string.Format("Error attempting to remove shortcut {0}\n\n {1}", path, ex.Message), "Error"); + } + } } } |
