Skip to content

Commit

Permalink
Added support for reading config file in package extras folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Dieckmann committed Jul 24, 2018
1 parent 3346ed1 commit d38ceae
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Monito.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@ public void Dispose() { }
public void Startup(ViewStartupParams p)
{
startupParams = p;
string configPath = this.GetType().Assembly.Location;
try
string configPath = this.GetType().Assembly.Location + ".config";
if (!File.Exists(configPath)) { configPath = configPath.Replace("bin\\Monito", "extra\\Monito"); }
if (File.Exists(configPath))
{
Configuration myDllConfig = ConfigurationManager.OpenExeConfiguration(configPath);
var map = new ExeConfigurationFileMap() { ExeConfigFilename = configPath };
Configuration myDllConfig = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
AppSettingsSection myDllConfigAppSettings = (AppSettingsSection)myDllConfig.GetSection("appSettings");
monitoSettings = myDllConfigAppSettings.Settings;
monitoSettingsLoaded = true;
}
catch { MessageBox.Show("Couldn't find, load or read DynaMonito config file at " + configPath); }
else { MessageBox.Show("Couldn't find, load or read DynaMonito config file at " + configPath); }
}

public void Loaded(ViewLoadedParams p)
Expand Down

0 comments on commit d38ceae

Please sign in to comment.