diff --git a/BatchMuxer_SubEd_Console/classes/util.cs b/BatchMuxer_SubEd_Console/classes/util.cs index 10ec090..e64f762 100644 --- a/BatchMuxer_SubEd_Console/classes/util.cs +++ b/BatchMuxer_SubEd_Console/classes/util.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection; namespace BatchMuxer_SubEd_Console.Classes {/// @@ -105,6 +106,7 @@ public static bool RenameFile(FileInfo[] fi) return hasRenamed; } + /// /// Update appsetting.json /// @@ -112,13 +114,15 @@ public static bool RenameFile(FileInfo[] fi) /// new value public static void WriteToConfig(string key, string value) { - string json = File.ReadAllText("appsettings.json"); + string appSettingPath = + Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "appsettings.json"); + string json = File.ReadAllText(appSettingPath); var application = new Application(); JsonConvert.PopulateObject(json, application); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["application"][key] = value; string output = Newtonsoft.Json.JsonConvert.SerializeObject(jsonObj, Formatting.Indented); - File.WriteAllText("appsettings.json", output); + File.WriteAllText(appSettingPath, output); } } } \ No newline at end of file