As I\'m polishing my little pet project, I\'m trying to store all the constant strings in my app.config file (Keys, XpathExpressions etc). When I run the compiled exe this w
I think I provide below the best of both worlds from the two most voted answers above (especially for people writing fsx scripts):
Given this app.config file:
Read foo
this way:
let appConfigPath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "app.config")
let fileMap = ExeConfigurationFileMap()
fileMap.ExeConfigFilename <- appConfigPath
let config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None)
let foo = config.AppSettings.Settings.["foo"].Value
Console.WriteLine(foo)