From 9937dbb7c90c5f72004070ca6b0c85c37b122da2 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Wed, 8 Apr 2020 16:14:28 +1000 Subject: [PATCH] Add prompt for opening location + update message (#176) --- Wox.Core/Configuration/Portable.cs | 19 ++++++++++++------- Wox.Plugin/SharedCommands/FilesFolders.cs | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/Wox.Core/Configuration/Portable.cs b/Wox.Core/Configuration/Portable.cs index ee916001b..a41ce02ed 100644 --- a/Wox.Core/Configuration/Portable.cs +++ b/Wox.Core/Configuration/Portable.cs @@ -163,22 +163,27 @@ public void PreStartCleanUpAfterPortabilityUpdate() if (DataLocationRoamingDeleteRequired) { - if(roamingDataPath.LocationExists()) - MessageBox.Show("Wox detected you restarted after enabling portable mode, " + - "your roaming data profile will now be deleted"); - FilesFolders.RemoveFolderIfExists(roamingDataPath); + if (MessageBox.Show("Wox has detected you enabled portable mode, " + + "would you like to move it to a different location?", string.Empty, + MessageBoxButton.YesNo) == MessageBoxResult.Yes) + { + FilesFolders.OpenLocationInExporer(Constant.RootDirectory); + + Environment.Exit(0); + } + return; } if(DataLocationPortableDeleteRequired) { - MessageBox.Show("Wox detected you restarted after disabling portable mode, " + - "your portable data profile will now be deleted"); - FilesFolders.RemoveFolderIfExists(portableDataPath); + MessageBox.Show("Wox has detected you disabled portable mode, " + + "the relevant shortcuts and uninstaller entry have been created"); + return; } } diff --git a/Wox.Plugin/SharedCommands/FilesFolders.cs b/Wox.Plugin/SharedCommands/FilesFolders.cs index f9eb13961..9e221fe61 100644 --- a/Wox.Plugin/SharedCommands/FilesFolders.cs +++ b/Wox.Plugin/SharedCommands/FilesFolders.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.IO; using System.Windows; @@ -107,5 +108,22 @@ public static bool FileExits(this string filePath) { return File.Exists(filePath); } + + public static void OpenLocationInExporer(string location) + { + try + { + if (LocationExists(location)) + Process.Start(location); + } + catch (Exception e) + { +#if DEBUG + throw e; +#else + MessageBox.Show(string.Format("Unable to open location {0}, please check if it exists", location)); +#endif + } + } } }