From 6e8337c563e4beda2912f7d9da3239e5ee4b958c Mon Sep 17 00:00:00 2001 From: Davide Giacometti Date: Tue, 3 Nov 2020 10:36:16 +0100 Subject: [PATCH] [PT Run] Folder path starting with backslash (#7711) * folder plugin path starting with backslash * handle single \ input --- .../Sources/Path/FolderHelper.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Sources/Path/FolderHelper.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Sources/Path/FolderHelper.cs index 41cff7a8ce..6e18018bb8 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Sources/Path/FolderHelper.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Sources/Path/FolderHelper.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; +using System.IO; using System.Linq; namespace Microsoft.Plugin.Folder.Sources @@ -78,6 +79,17 @@ namespace Microsoft.Plugin.Folder.Sources public static string Expand(string search) { + if (search == null) + { + throw new ArgumentNullException(nameof(search)); + } + + // Absolute path of system drive: \Windows\System32 + if (search[0] == '\\' && (search.Length == 1 || search[1] != '\\')) + { + search = Path.Combine(Path.GetPathRoot(Environment.SystemDirectory), search.Substring(1)); + } + return Environment.ExpandEnvironmentVariables(search); } }