Browse Source

Fixed appsettings relative directory

Krzysztof Krysiński 1 month ago
parent
commit
d4ea49c69e
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/PixiEditor/RuntimeConstants.cs

+ 5 - 1
src/PixiEditor/RuntimeConstants.cs

@@ -1,3 +1,5 @@
+using System.Diagnostics;
+
 namespace PixiEditor;
 
 public static class RuntimeConstants
@@ -8,7 +10,9 @@ public static class RuntimeConstants
 
     private static string ReadAppSettings()
     {
-        using StreamReader reader = new StreamReader("appsettings.json");
+        string installDirPath = Process.GetCurrentProcess().MainModule?.FileName;
+        string appsettingsPath = Path.Combine(Path.GetDirectoryName(installDirPath) ?? string.Empty, "appsettings.json");
+        using StreamReader reader = new StreamReader(appsettingsPath);
         return reader.ReadToEnd();
     }