From ac02495e80c3e3dfa8ec8cb3603175bfee06b025 Mon Sep 17 00:00:00 2001 From: Archi Date: Mon, 29 Nov 2021 23:32:51 +0100 Subject: [PATCH] Replace ~ in path with user's home location --- ArchiSteamFarm/Program.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index e289bb11f..78e51c88d 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -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) {