diff --git a/DICUI.Library/Utilities/DumpEnvironment.cs b/DICUI.Library/Utilities/DumpEnvironment.cs index 52fd2468..9905f798 100644 --- a/DICUI.Library/Utilities/DumpEnvironment.cs +++ b/DICUI.Library/Utilities/DumpEnvironment.cs @@ -246,6 +246,7 @@ namespace DICUI.Utilities { // Cache if we had a directory separator or not bool endedWithDirectorySeparator = OutputDirectory.EndsWith(Path.DirectorySeparatorChar.ToString()); + bool endedWithSpace = OutputDirectory.TrimEnd(Path.DirectorySeparatorChar).EndsWith(" "); // Normalize the path so the below filters work better string combinedPath = Path.Combine(OutputDirectory, OutputFilename); @@ -268,6 +269,10 @@ namespace DICUI.Utilities foreach (char c in Path.GetInvalidFileNameChars()) OutputFilename = OutputFilename.Replace(c, '_'); + // If we had a space at the end before, add it again + if (endedWithSpace) + OutputDirectory += " "; + // If we had a directory separator at the end before, add it again if (endedWithDirectorySeparator) OutputDirectory += Path.DirectorySeparatorChar;