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
This commit is contained in:
RKrom 2013-03-07 11:17:20 +00:00
commit 51e57b8943

View file

@ -1239,24 +1239,28 @@ namespace Greenshot {
/// The Contextmenu_OpenRecent currently opens the last know save location /// The Contextmenu_OpenRecent currently opens the last know save location
/// </summary> /// </summary>
private void Contextmenu_OpenRecent(object sender, EventArgs eventArgs) { private void Contextmenu_OpenRecent(object sender, EventArgs eventArgs) {
string path; string path = FilenameHelper.FillVariables(conf.OutputFilePath, false);
string configPath = FilenameHelper.FillVariables(conf.OutputFilePath, false); // Fix for #1470, problems with a drive which is no longer available
string lastFilePath = Path.GetDirectoryName(conf.OutputFileAsFullpath); try {
if (Directory.Exists(lastFilePath)) { string lastFilePath = Path.GetDirectoryName(conf.OutputFileAsFullpath);
path = lastFilePath; if (Directory.Exists(lastFilePath)) {
} else if (Directory.Exists(configPath)) { path = lastFilePath;
path = configPath; } else if (!Directory.Exists(path)) {
} else { // What do I open when nothing can be found? Right, nothing...
// What do I open when nothing can be found? Right, nothing... return;
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); LOG.Debug("DoubleClick was called! Starting: " + path);
try { try {
System.Diagnostics.Process.Start(path); System.Diagnostics.Process.Start(path);
} catch (Exception e) { } catch (Exception ex) {
// Make sure we show what we tried to open in the exception // Make sure we show what we tried to open in the exception
e.Data.Add("path", path); ex.Data.Add("path", path);
throw; 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);
} }
} }