diff --git a/dev/pyRevitLabs/pyRevitLabs.Common/UserEnv.cs b/dev/pyRevitLabs/pyRevitLabs.Common/UserEnv.cs index 269f81ca6..e703694e0 100644 --- a/dev/pyRevitLabs/pyRevitLabs.Common/UserEnv.cs +++ b/dev/pyRevitLabs/pyRevitLabs.Common/UserEnv.cs @@ -52,7 +52,10 @@ public static Version GetInstalledDotNetVersion() { public static List GetInstalledDotnetTargetPacks() { var targetPackPaths = new List(); - var frameworkPath = @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework"; + var frameworkPath = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), + @"Reference Assemblies\Microsoft\Framework\.NETFramework" + ); foreach (string path in Directory.GetDirectories(frameworkPath)) if (Regex.Match(Path.GetFileName(path), @"\d\..+").Success) targetPackPaths.Add(path); @@ -61,7 +64,10 @@ public static List GetInstalledDotnetTargetPacks() { public static List GetInstalledDotnetCoreTargetPacks() { var targetPackPaths = new List(); - var frameworkPath = @"C:\Program Files\dotnet\sdk"; + var frameworkPath = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), + @"dotnet\sdk" + ); foreach (string path in Directory.GetDirectories(frameworkPath)) if (Regex.Match(Path.GetFileName(path), @"\d\..+").Success) targetPackPaths.Add(path); @@ -80,7 +86,8 @@ public static string GetLoggedInUserName() { foreach (ManagementObject oReturn in oReturnCollection) { return oReturn["UserName"].ToString(); } - } catch (Exception ex) { + } + catch (Exception ex) { logger.Debug("Failed to get logged in username. | {0}", ex.Message); } return null;