From ce5ae2d149a7077e69a935c0dfdb9701817ae873 Mon Sep 17 00:00:00 2001
From: Tyler <tylerbren@gmail.com>
Date: Fri, 9 Jun 2023 10:02:23 -0500
Subject: [PATCH] Move config file to //%appdata%/roaming/EVE-O Preview/EVE-O
 Preview.json to allow installs from anywhere.

---
 .../Implementation/ConfigurationStorage.cs      | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/Eve-O-Preview/Configuration/Implementation/ConfigurationStorage.cs b/src/Eve-O-Preview/Configuration/Implementation/ConfigurationStorage.cs
index 3419b74..497e395 100644
--- a/src/Eve-O-Preview/Configuration/Implementation/ConfigurationStorage.cs
+++ b/src/Eve-O-Preview/Configuration/Implementation/ConfigurationStorage.cs
@@ -1,4 +1,5 @@
-using System.IO;
+using System;
+using System.IO;
 using Newtonsoft.Json;
 
 namespace EveOPreview.Configuration.Implementation
@@ -6,15 +7,21 @@ namespace EveOPreview.Configuration.Implementation
 	class ConfigurationStorage : IConfigurationStorage
 	{
 		private const string CONFIGURATION_FILE_NAME = "EVE-O Preview.json";
+        private const string CONFIGURATION_DIRECTORY_NAME = "EVE-O Preview";
+        private string _configurationFile;
 
-		private readonly IAppConfig _appConfig;
+        private readonly IAppConfig _appConfig;
 		private readonly IThumbnailConfiguration _thumbnailConfiguration;
 
 		public ConfigurationStorage(IAppConfig appConfig, IThumbnailConfiguration thumbnailConfiguration)
 		{
 			this._appConfig = appConfig;
-			this._thumbnailConfiguration = thumbnailConfiguration;
-		}
+            this._thumbnailConfiguration = thumbnailConfiguration;
+            //%appdata%/roaming/EVE-O Preview/EVE-O Preview.json
+            string configurationPath = Directory.CreateDirectory(
+                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), CONFIGURATION_DIRECTORY_NAME)).FullName;
+            _configurationFile = Path.Combine(configurationPath, CONFIGURATION_FILE_NAME);
+        }
 
 		public void Load()
 		{
@@ -50,7 +57,7 @@ public void Save()
 
 		private string GetConfigFileName()
 		{
-			return string.IsNullOrEmpty(this._appConfig.ConfigFileName) ? ConfigurationStorage.CONFIGURATION_FILE_NAME : this._appConfig.ConfigFileName;
+			return string.IsNullOrEmpty(this._appConfig.ConfigFileName) ? _configurationFile : this._appConfig.ConfigFileName;
 		}
 	}
 }
\ No newline at end of file