diff --git a/ArchiSteamFarm/IPC.cs b/ArchiSteamFarm/IPC.cs index 34e772dac..c345f9a43 100644 --- a/ArchiSteamFarm/IPC.cs +++ b/ArchiSteamFarm/IPC.cs @@ -795,7 +795,7 @@ namespace ArchiSteamFarm { string argument = WebUtility.UrlDecode(string.Join("", arguments.Skip(argumentsIndex))); - string directory = Path.Combine(SharedInfo.WebsiteDirectory, argument); + string directory = Path.Combine(SharedInfo.HomeDirectory, SharedInfo.WebsiteDirectory, argument); if (!Directory.Exists(directory)) { await ResponseJsonObject(request, response, new GenericResponse>(false, string.Format(Strings.ErrorIsInvalid, nameof(directory))), HttpStatusCode.BadRequest).ConfigureAwait(false); return true; @@ -837,7 +837,7 @@ namespace ArchiSteamFarm { return false; } - string filePath = SharedInfo.WebsiteDirectory + Path.DirectorySeparatorChar + absolutePath.Replace("/", Path.DirectorySeparatorChar.ToString()); + string filePath = Path.Combine(SharedInfo.HomeDirectory, SharedInfo.WebsiteDirectory) + Path.DirectorySeparatorChar + absolutePath.Replace("/", Path.DirectorySeparatorChar.ToString()); if (Directory.Exists(filePath)) { filePath = Path.Combine(filePath, "index.html"); } diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index f2978bfe3..90b6803c5 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -209,24 +209,21 @@ namespace ArchiSteamFarm { } private static void InitCore(IReadOnlyCollection args) { - string homeDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); - if (!string.IsNullOrEmpty(homeDirectory)) { - Directory.SetCurrentDirectory(homeDirectory); + Directory.SetCurrentDirectory(SharedInfo.HomeDirectory); - // Allow loading configs from source tree if it's a debug build - if (Debugging.IsDebugBuild) { - // Common structure is bin/(x64/)Debug/ArchiSteamFarm.exe, so we allow up to 4 directories up - for (byte i = 0; i < 4; i++) { - Directory.SetCurrentDirectory(".."); - if (Directory.Exists(SharedInfo.ConfigDirectory)) { - break; - } + // Allow loading configs from source tree if it's a debug build + if (Debugging.IsDebugBuild) { + // Common structure is bin/(x64/)Debug/ArchiSteamFarm.exe, so we allow up to 4 directories up + for (byte i = 0; i < 4; i++) { + Directory.SetCurrentDirectory(".."); + if (Directory.Exists(SharedInfo.ConfigDirectory)) { + break; } + } - // If config directory doesn't exist after our adjustment, abort all of that - if (!Directory.Exists(SharedInfo.ConfigDirectory)) { - Directory.SetCurrentDirectory(homeDirectory); - } + // If config directory doesn't exist after our adjustment, abort all of that + if (!Directory.Exists(SharedInfo.ConfigDirectory)) { + Directory.SetCurrentDirectory(SharedInfo.HomeDirectory); } } diff --git a/ArchiSteamFarm/SharedInfo.cs b/ArchiSteamFarm/SharedInfo.cs index 5bcae4cdd..11f8b1186 100644 --- a/ArchiSteamFarm/SharedInfo.cs +++ b/ArchiSteamFarm/SharedInfo.cs @@ -21,6 +21,7 @@ using System; using System.Diagnostics.CodeAnalysis; +using System.IO; using System.Reflection; namespace ArchiSteamFarm { @@ -48,6 +49,7 @@ namespace ArchiSteamFarm { internal const string UpdateDirectory = "_old"; internal const string WebsiteDirectory = "www"; + internal static string HomeDirectory => Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); internal static Guid ModuleVersion => Assembly.GetEntryAssembly().ManifestModule.ModuleVersionId; internal static string PublicIdentifier => AssemblyName + (BuildInfo.IsCustomBuild ? "-custom" : ""); internal static Version Version => Assembly.GetEntryAssembly().GetName().Version;