diff --git a/src/Gemstone/Configuration/INIConfigurationHelpers.cs b/src/Gemstone/Configuration/INIConfigurationHelpers.cs
index 4772530fe7..b8ee774095 100644
--- a/src/Gemstone/Configuration/INIConfigurationHelpers.cs
+++ b/src/Gemstone/Configuration/INIConfigurationHelpers.cs
@@ -23,6 +23,7 @@
using System;
using System.IO;
+using Gemstone.IO;
namespace Gemstone.Configuration;
@@ -35,11 +36,15 @@ internal static class INIConfigurationHelpers
/// Gets file path for INI configuration file.
///
/// Target file INI file name.
+ /// Any configured path for the INI file.
/// INI file path.
- public static string GetINIFilePath(string fileName)
+ public static string GetINIFilePath(string fileName, string? configuredINIPath)
{
- Environment.SpecialFolder specialFolder = Environment.SpecialFolder.CommonApplicationData;
- string appDataPath = Environment.GetFolderPath(specialFolder);
+ if (!string.IsNullOrWhiteSpace(configuredINIPath))
+ return Path.Combine(FilePath.GetAbsolutePath(configuredINIPath), fileName);
+
+ const Environment.SpecialFolder SpecialFolder = Environment.SpecialFolder.CommonApplicationData;
+ string appDataPath = Environment.GetFolderPath(SpecialFolder);
return Path.Combine(appDataPath, Common.ApplicationName, fileName);
}
diff --git a/src/Gemstone/Configuration/Settings.cs b/src/Gemstone/Configuration/Settings.cs
index ce5ebac940..87220b6131 100644
--- a/src/Gemstone/Configuration/Settings.cs
+++ b/src/Gemstone/Configuration/Settings.cs
@@ -128,6 +128,11 @@ public Settings()
///
public ConfigurationOperation INIFile { get; init; } = ConfigurationOperation.ReadOnly;
+ ///
+ /// Gets or sets any configured INI path. Set to null for default %ProgramData% path.
+ ///
+ public string? ConfiguredINIPath { get; init; } = null;
+
///
/// Gets or sets configuration operation mode for SQLite settings.
///
@@ -161,24 +166,12 @@ public ConfigurationOperation EnvironmentalVariables
///
/// Gets the names for the settings sections.
///
- public string[] SectionNames
- {
- get
- {
- return m_sections.Keys.ToArray();
- }
- }
+ public string[] SectionNames => m_sections.Keys.ToArray();
///
/// Gets the sections count for the settings.
///
- public int Count
- {
- get
- {
- return m_sections.Count;
- }
- }
+ public int Count => m_sections.Count;
///
/// Gets the command line switch mappings for .
@@ -189,23 +182,14 @@ public int Count
/// Gets the for the specified key.
///
/// Section key.
- public SettingsSection this[string key]
- {
- get
- {
- return m_sections.GetOrAdd(key, _ => new SettingsSection(this, key));
- }
- }
+ public SettingsSection this[string key] => m_sections.GetOrAdd(key, _ => new SettingsSection(this, key));
///
/// Gets flag that determines if any settings have been changed.
///
public bool IsDirty
{
- get
- {
- return m_sections.Values.Any(section => section.IsDirty);
- }
+ get => m_sections.Values.Any(section => section.IsDirty);
private set
{
foreach (SettingsSection section in m_sections.Values)
@@ -247,8 +231,8 @@ public void Bind(IConfigurationBuilder builder)
if (iniProviderExists)
{
- string iniPath = GetINIFilePath("settings.ini");
- using TextReader reader = GetINIFileReader(iniPath);
+ string iniFilePath = GetINIFilePath("settings.ini", ConfiguredINIPath);
+ using TextReader reader = GetINIFileReader(iniFilePath);
string[] iniFileContents = reader.ReadToEnd().Split(["\n", "\r", "\r\n"], StringSplitOptions.RemoveEmptyEntries);
string currentSection = "";
StringBuilder currentDescription = new();
@@ -440,7 +424,7 @@ private void SaveSections()
// Handle INI file as a special case, writing entire file contents on save
string contents = Configuration!.GenerateINIFileContents(splitDescriptionLines: SplitDescriptionLines);
- string iniFilePath = GetINIFilePath("settings.ini");
+ string iniFilePath = GetINIFilePath("settings.ini", ConfiguredINIPath);
using TextWriter writer = GetINIFileWriter(iniFilePath);
writer.Write(contents);
}