From 463a543eb63398773c1967e541160a1cde99e01e Mon Sep 17 00:00:00 2001 From: Marcel Houweling Date: Sat, 19 Mar 2022 09:50:25 +0100 Subject: [PATCH] add JournalPath to appsettings.config --- Elite/History.cs | 19 +++++++++++++++++++ Elite/appsettings.config | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Elite/History.cs b/Elite/History.cs index 3b825a0..85c583e 100644 --- a/Elite/History.cs +++ b/Elite/History.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Collections.Specialized; +using System.Configuration; using System.Drawing; using System.Globalization; using System.IO; @@ -84,6 +86,11 @@ public static extern int SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct) IntPtr hToken, out IntPtr ppszPath); } + private static string GetExePath() + { + var strExeFilePath = System.Reflection.Assembly.GetExecutingAssembly().Location; + return Path.GetDirectoryName(strExeFilePath); + } /// /// The standard Directory of the Player Journal files (C:\Users\%username%\Saved Games\Frontier Developments\Elite Dangerous). @@ -92,6 +99,18 @@ private static DirectoryInfo StandardDirectory { get { + var exePath = GetExePath(); + + if (File.Exists(Path.Combine(exePath, "appSettings.config")) && + ConfigurationManager.GetSection("appSettings") is NameValueCollection appSection) + { + var journalPath = appSection["JournalPath"]; + if (!string.IsNullOrEmpty(journalPath)) + { + return new DirectoryInfo(journalPath); + } + } + //#if DEBUG //return new DirectoryInfo(@"C:\Users\Marcel\Desktop\Elite Dangerous"); //#endif diff --git a/Elite/appsettings.config b/Elite/appsettings.config index d3a1513..d80a559 100644 --- a/Elite/appsettings.config +++ b/Elite/appsettings.config @@ -1,5 +1,6 @@ - + + \ No newline at end of file