From d49c211882b9dfe65b0f98b60416d6523e4e79bd Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 23 Jul 2025 11:40:05 -0400 Subject: [PATCH] Add GetHomeDirectory --- SabreTools.IO/PathTool.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/SabreTools.IO/PathTool.cs b/SabreTools.IO/PathTool.cs index a92e903..0ba0db1 100644 --- a/SabreTools.IO/PathTool.cs +++ b/SabreTools.IO/PathTool.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.IO; using SabreTools.IO.Extensions; @@ -166,6 +167,18 @@ namespace SabreTools.IO return infiles; } + /// + /// Get the home directory for the current user + /// + public static string GetHomeDirectory() + { +#if NET20 || NET35 + return Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%"); +#else + return Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); +#endif + } + /// /// Get the runtime directory /// @@ -174,7 +187,7 @@ namespace SabreTools.IO #if NET20 || NET35 || NET40 || NET452 return Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); #else - return System.AppContext.BaseDirectory; + return AppContext.BaseDirectory; #endif } }