diff --git a/GreenshotOfficePlugin/Destinations/ExcelDestination.cs b/GreenshotOfficePlugin/Destinations/ExcelDestination.cs
index 51392c79b..447aa00db 100644
--- a/GreenshotOfficePlugin/Destinations/ExcelDestination.cs
+++ b/GreenshotOfficePlugin/Destinations/ExcelDestination.cs
@@ -124,8 +124,8 @@ namespace GreenshotOfficePlugin {
exportInformation.ExportMade = true;
ProcessExport(exportInformation, surface);
// Cleanup imageFile if we created it here, so less tmp-files are generated and left
- if (createdFile && File.Exists(imageFile)) {
- File.Delete(imageFile);
+ if (createdFile) {
+ ImageOutput.DeleteNamedTmpFile(imageFile);
}
return exportInformation;
}
diff --git a/GreenshotPlugin/Core/ImageOutput.cs b/GreenshotPlugin/Core/ImageOutput.cs
index f20ea5e56..ffda8f488 100644
--- a/GreenshotPlugin/Core/ImageOutput.cs
+++ b/GreenshotPlugin/Core/ImageOutput.cs
@@ -541,6 +541,25 @@ namespace GreenshotPlugin.Core {
return tmpFile;
}
+ ///
+ /// Remove a tmpfile which was created by SaveNamedTmpFile
+ /// Used e.g. by the email export
+ ///
+ ///
+ /// true if it worked
+ public static bool DeleteNamedTmpFile(string tmpfile) {
+ LOG.Debug("Deleting TMP File: " + tmpfile);
+ try {
+ if (File.Exists(tmpfile)) {
+ File.Delete(tmpfile);
+ tmpFileCache.Remove(tmpfile);
+ }
+ return true;
+ } catch (Exception e) {
+ }
+ return false;
+ }
+
///
/// Helper method to create a temp image file
///