Added tmp-file cleanup, including the cached entry, currently only for Excel.

This commit is contained in:
RKrom 2014-02-07 13:29:54 +01:00
parent 1c0dc61bd8
commit fa79ebb727
2 changed files with 21 additions and 2 deletions

View file

@ -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;
}

View file

@ -541,6 +541,25 @@ namespace GreenshotPlugin.Core {
return tmpFile;
}
/// <summary>
/// Remove a tmpfile which was created by SaveNamedTmpFile
/// Used e.g. by the email export
/// </summary>
/// <param name="tmpfile"></param>
/// <returns>true if it worked</returns>
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;
}
/// <summary>
/// Helper method to create a temp image file
/// </summary>