Replace ~ in path with user's home location

This commit is contained in:
Archi
2021-11-29 23:32:51 +01:00
parent 67c5e1f7c4
commit ac02495e80

View File

@@ -124,6 +124,19 @@ internal static class Program {
throw new ArgumentNullException(nameof(path));
}
// Aid userspace and replace ~ with user's home directory if possible
if (path.Contains('~', StringComparison.Ordinal)) {
try {
string homeDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
if (!string.IsNullOrEmpty(homeDirectory)) {
path = path.Replace("~", homeDirectory, StringComparison.Ordinal);
}
} catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e);
}
}
try {
Directory.SetCurrentDirectory(path);
} catch (Exception e) {