From 51e57b8943444635322044682eb42b7b6c038d9f Mon Sep 17 00:00:00 2001 From: RKrom Date: Thu, 7 Mar 2013 11:17:20 +0000 Subject: [PATCH] Fix for #1470, preventing Exception pop-up (showing a message instead) and using fall-back if the last location is no longer available. git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2525 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- Greenshot/Forms/MainForm.cs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs index 63b6037e8..73e1e2a27 100644 --- a/Greenshot/Forms/MainForm.cs +++ b/Greenshot/Forms/MainForm.cs @@ -1239,24 +1239,28 @@ namespace Greenshot { /// The Contextmenu_OpenRecent currently opens the last know save location /// private void Contextmenu_OpenRecent(object sender, EventArgs eventArgs) { - string path; - string configPath = FilenameHelper.FillVariables(conf.OutputFilePath, false); - string lastFilePath = Path.GetDirectoryName(conf.OutputFileAsFullpath); - if (Directory.Exists(lastFilePath)) { - path = lastFilePath; - } else if (Directory.Exists(configPath)) { - path = configPath; - } else { - // What do I open when nothing can be found? Right, nothing... - return; + string path = FilenameHelper.FillVariables(conf.OutputFilePath, false); + // Fix for #1470, problems with a drive which is no longer available + try { + string lastFilePath = Path.GetDirectoryName(conf.OutputFileAsFullpath); + if (Directory.Exists(lastFilePath)) { + path = lastFilePath; + } else if (!Directory.Exists(path)) { + // What do I open when nothing can be found? Right, nothing... + return; + } + } catch (Exception ex) { + LOG.Warn("Couldn't open the path to the last exported file, taking default.", ex); } LOG.Debug("DoubleClick was called! Starting: " + path); try { System.Diagnostics.Process.Start(path); - } catch (Exception e) { + } catch (Exception ex) { // Make sure we show what we tried to open in the exception - e.Data.Add("path", path); - throw; + ex.Data.Add("path", path); + LOG.Warn("Couldn't open the path to the last exported file", ex); + // No reason to create a bug-form, we just display the error. + MessageBox.Show(ex.Message, "Greenshot", MessageBoxButtons.OK, MessageBoxIcon.Error); } }