From 85f71032b546efbd72f3262994644375e18d2991 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 20 May 2019 15:00:41 -0700 Subject: [PATCH] Fix trailing space handling for output directory --- DICUI.Library/Utilities/DumpEnvironment.cs | 5 +++++ 1 file changed, 5 insertions(+) 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;