diff --git a/Greenshot/Destinations/FileDestination.cs b/Greenshot/Destinations/FileDestination.cs
index 0c52af596..daada3f41 100644
--- a/Greenshot/Destinations/FileDestination.cs
+++ b/Greenshot/Destinations/FileDestination.cs
@@ -115,11 +115,7 @@ namespace Greenshot.Destinations {
pattern = "greenshot ${capturetime}";
}
string filename = FilenameHelper.GetFilenameFromPattern(pattern, CoreConfig.OutputFileFormat, captureDetails);
- // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC)
- if (!File.Exists(CoreConfig.OutputFilePath))
- {
- CoreConfig.OutputFilePath = CoreConfig.GetDefault(nameof(CoreConfig.OutputFilePath)) as string;
- }
+ CoreConfig.ValidateAndCorrectOutputFilePath();
string filepath = FilenameHelper.FillVariables(CoreConfig.OutputFilePath, false);
try {
fullPath = Path.Combine(filepath, filename);
diff --git a/GreenshotPlugin/Controls/SaveImageFileDialog.cs b/GreenshotPlugin/Controls/SaveImageFileDialog.cs
index 7750a1dce..c077b4093 100644
--- a/GreenshotPlugin/Controls/SaveImageFileDialog.cs
+++ b/GreenshotPlugin/Controls/SaveImageFileDialog.cs
@@ -68,13 +68,7 @@ namespace GreenshotPlugin.Controls {
ApplyFilterOptions();
string initialDirectory = null;
try {
- // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC)
- var outputFilePath = Path.GetDirectoryName(conf.OutputFileAsFullpath);
- if (outputFilePath == null || (!File.Exists(conf.OutputFileAsFullpath) && !Directory.Exists(outputFilePath)))
- {
- conf.OutputFileAsFullpath = conf.GetDefault(nameof(conf.OutputFileAsFullpath)) as string;
- }
-
+ conf.ValidateAndCorrectOutputFileAsFullpath();
initialDirectory = Path.GetDirectoryName(conf.OutputFileAsFullpath);
} catch {
LOG.WarnFormat("OutputFileAsFullpath was set to {0}, ignoring due to problem in path.", conf.OutputFileAsFullpath);
diff --git a/GreenshotPlugin/Core/CoreConfiguration.cs b/GreenshotPlugin/Core/CoreConfiguration.cs
index a08392109..4d60bb5aa 100644
--- a/GreenshotPlugin/Core/CoreConfiguration.cs
+++ b/GreenshotPlugin/Core/CoreConfiguration.cs
@@ -515,5 +515,29 @@ namespace GreenshotPlugin.Core {
WebRequestReadWriteTimeout = 100;
}
}
+
+ ///
+ /// Validate the OutputFilePath, and if this is not correct it will be set to the default
+ /// Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC)
+ ///
+ public void ValidateAndCorrectOutputFilePath()
+ {
+ if (!Directory.Exists(OutputFilePath))
+ {
+ OutputFilePath = GetDefault(nameof(OutputFilePath)) as string;
+ }
+ }
+ ///
+ /// Validate the OutputFileAsFullpath, and if this is not correct it will be set to the default
+ /// Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC)
+ ///
+ public void ValidateAndCorrectOutputFileAsFullpath()
+ {
+ var outputFilePath = Path.GetDirectoryName(OutputFileAsFullpath);
+ if (outputFilePath == null || (!File.Exists(OutputFileAsFullpath) && !Directory.Exists(outputFilePath)))
+ {
+ OutputFileAsFullpath = GetDefault(nameof(OutputFileAsFullpath)) as string;
+ }
+ }
}
}
\ No newline at end of file