From 755f1b8e95cfac338588a59198fb46308c2c337e Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sun, 29 Sep 2019 21:28:20 -0700 Subject: [PATCH] Root directories are weird (Fixes #163) --- DICUI.Library/Utilities/DumpEnvironment.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/DICUI.Library/Utilities/DumpEnvironment.cs b/DICUI.Library/Utilities/DumpEnvironment.cs index 6f89db65..e8236d3f 100644 --- a/DICUI.Library/Utilities/DumpEnvironment.cs +++ b/DICUI.Library/Utilities/DumpEnvironment.cs @@ -273,6 +273,16 @@ namespace DICUI.Utilities // If we had a directory separator at the end before, add it again if (endedWithDirectorySeparator) OutputDirectory += Path.DirectorySeparatorChar; + + // If we have a root directory, sanitize + if (Directory.Exists(OutputDirectory)) + { + var possibleRootDir = new DirectoryInfo(OutputDirectory); + if (possibleRootDir.Parent == null) + { + OutputDirectory = OutputDirectory.Replace($"{Path.DirectorySeparatorChar}{Path.DirectorySeparatorChar}", $"{Path.DirectorySeparatorChar}"); + } + } } catch {