Additional fix for #1499

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2568 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2013-04-18 15:15:05 +00:00
commit 7275ad6222

View file

@ -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 {