From 7275ad622212a3c14e7df3b1666eddbd44ab6e67 Mon Sep 17 00:00:00 2001 From: RKrom Date: Thu, 18 Apr 2013 15:15:05 +0000 Subject: [PATCH] Additional fix for #1499 git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2568 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- Greenshot/Helpers/CaptureHelper.cs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Greenshot/Helpers/CaptureHelper.cs b/Greenshot/Helpers/CaptureHelper.cs index 529770962..5e46147a5 100644 --- a/Greenshot/Helpers/CaptureHelper.cs +++ b/Greenshot/Helpers/CaptureHelper.cs @@ -594,6 +594,8 @@ namespace Greenshot.Helpers { balloonTipClickedHandler = delegate(object sender, EventArgs e) { if (eventArgs.MessageType == SurfaceMessageTyp.FileSaved) { if (!string.IsNullOrEmpty(surface.LastSaveFullPath)) { + string errorMessage = null; + try { ProcessStartInfo psi = new ProcessStartInfo("explorer.exe"); psi.Arguments = Path.GetDirectoryName(surface.LastSaveFullPath); @@ -602,7 +604,27 @@ namespace Greenshot.Helpers { p.StartInfo = psi; p.Start(); } catch (Exception ex) { - MessageBox.Show(string.Format("{0}\r\nexplorer.exe {1}", ex.Message, surface.LastSaveFullPath), "explorer.exe", MessageBoxButtons.OK, MessageBoxIcon.Error); + errorMessage = ex.Message; + } + // Added fallback for when the explorer can't be found + if (errorMessage != null) { + try { + string windowsPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows); + string explorerPath = Path.Combine(windowsPath, "explorer.exe"); + if (File.Exists(explorerPath)) { + ProcessStartInfo psi = new ProcessStartInfo(explorerPath); + psi.Arguments = Path.GetDirectoryName(surface.LastSaveFullPath); + psi.UseShellExecute = false; + Process p = new Process(); + p.StartInfo = psi; + p.Start(); + errorMessage = null; + } + } catch { + } + } + if (errorMessage != null) { + MessageBox.Show(string.Format("{0}\r\nexplorer.exe {1}", errorMessage, surface.LastSaveFullPath), "explorer.exe", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else {