Fix trailing space handling for output directory

This commit is contained in:
Matt Nadareski
2019-05-20 15:00:41 -07:00
parent ead530e2ec
commit 85f71032b5

View File

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