Add GetHomeDirectory

This commit is contained in:
Matt Nadareski
2025-07-23 11:40:05 -04:00
parent f2bdc815b8
commit d49c211882

View File

@@ -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;
}
/// <summary>
/// Get the home directory for the current user
/// </summary>
public static string GetHomeDirectory()
{
#if NET20 || NET35
return Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%");
#else
return Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
#endif
}
/// <summary>
/// Get the runtime directory
/// </summary>
@@ -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
}
}