/// <summary> /// Loads config on program start /// </summary> public void Load() { if (!Directory.Exists(CfgFolderPath)) { Directory.CreateDirectory(CfgFolderPath); } if (File.Exists(CfgFilePath)) { _settings.Reset(); try { Read(); } catch { Save(); throw; } } try { _settings.Validate(); } catch (ArgumentNullException) { // There were missing config fields. Regenerate it and read it in Save(); Read(); _settings.Validate(); } }
/// <summary> /// Recreates the config with default values /// </summary> public void Reset() { _settings.Reset(); Save(); }