diff --git a/Greenshot/Configuration/LanguageKeys.cs b/Greenshot/Configuration/LanguageKeys.cs
index fc08c50bc..2cb7d3fb0 100644
--- a/Greenshot/Configuration/LanguageKeys.cs
+++ b/Greenshot/Configuration/LanguageKeys.cs
@@ -156,6 +156,7 @@ namespace Greenshot.Configuration {
error_openfile,
error_openlink,
error_save,
+ error_save_invalid_chars,
help_title,
jpegqualitydialog_choosejpegquality,
qualitydialog_dontaskagain,
diff --git a/Greenshot/Destinations/FileDestination.cs b/Greenshot/Destinations/FileDestination.cs
index e08ddfff6..45454a395 100644
--- a/Greenshot/Destinations/FileDestination.cs
+++ b/Greenshot/Destinations/FileDestination.cs
@@ -84,14 +84,7 @@ namespace Greenshot.Destinations {
fullPath = captureDetails.Filename;
outputSettings.Format = ImageOutput.FormatForFilename(fullPath);
} else {
- LOG.InfoFormat("Creating new filename");
- string pattern = conf.OutputFileFilenamePattern;
- if (string.IsNullOrEmpty(pattern)) {
- pattern = "greenshot ${capturetime}";
- }
- string filename = FilenameHelper.GetFilenameFromPattern(pattern, conf.OutputFileFormat, captureDetails);
- string filepath = FilenameHelper.FillVariables(conf.OutputFilePath, false);
- fullPath = Path.Combine(filepath, filename);
+ fullPath = CreateNewFilename(captureDetails);
// As we generate a file, the configuration tells us if we allow to overwrite
overwrite = conf.OutputFileAllowOverwrite;
}
@@ -130,5 +123,35 @@ namespace Greenshot.Destinations {
ProcessExport(exportInformation, surface);
return exportInformation;
}
+
+ private static string CreateNewFilename(ICaptureDetails captureDetails) {
+ string fullPath;
+ LOG.InfoFormat("Creating new filename");
+ string pattern = conf.OutputFileFilenamePattern;
+ if (string.IsNullOrEmpty(pattern)) {
+ pattern = "greenshot ${capturetime}";
+ }
+ string filename = FilenameHelper.GetFilenameFromPattern(pattern, conf.OutputFileFormat, captureDetails);
+ string filepath = FilenameHelper.FillVariables(conf.OutputFilePath, false);
+ try {
+ fullPath = Path.Combine(filepath, filename);
+ } catch (ArgumentException ae) {
+ // configured filename or path not valid, show error message...
+ LOG.InfoFormat("Generated path or filename not valid: {0}, {1}", filepath, filename);
+
+ MessageBox.Show(Language.GetString(LangKey.error_save_invalid_chars), Language.GetString(LangKey.error));
+ // ... lets get the pattern fixed....
+ var dialogResult = new SettingsForm().ShowDialog();
+ if (dialogResult == DialogResult.OK) {
+ // ... OK -> then try again:
+ fullPath = CreateNewFilename(captureDetails);
+ } else {
+ // ... cancelled.
+ fullPath = null;
+ }
+
+ }
+ return fullPath;
+ }
}
}
diff --git a/Greenshot/Languages/language-de-DE.xml b/Greenshot/Languages/language-de-DE.xml
index c38b5c59b..d990b164a 100644
--- a/Greenshot/Languages/language-de-DE.xml
+++ b/Greenshot/Languages/language-de-DE.xml
@@ -164,6 +164,7 @@ Bitte überprüfen Sie die Schreibrechte oder wählen Sie einen anderen Speicher
Die Datei "{0}" konnte nicht geöffnet werden.
Konnte Link '{0}' nicht öffnen.
Screenshot konnte nicht gespeichert werden, bitte wählen Sie einen anderen Speicherort.
+ Der generierte Datei- oder Verzeichnisname ist nicht gültig. Bitte korrigieren Sie das Dateiname-Muster und versuchen Sie es erneut.
Experten
8-Bit-Bilder erstellen bei weniger als 256 Farben
Auch instabile Updates anbieten
diff --git a/Greenshot/Languages/language-en-US.xml b/Greenshot/Languages/language-en-US.xml
index a938e9680..a06d779bd 100644
--- a/Greenshot/Languages/language-en-US.xml
+++ b/Greenshot/Languages/language-en-US.xml
@@ -164,6 +164,7 @@ Please check write accessibility of the selected storage location.
The file "{0}" could not be opened.
Could not open link '{0}'.
Could not save screenshot, please find a suitable location.
+ The generated filename or directory name is not valid. Please fix the filename pattern and then try again.
Expert
Create an 8-bit image if the colors are less than 256 while having a > 8 bits image
Check for unstable updates