any hints as to why this throws a "configuration file was not found and is not optional" exception?
string relative_path = "../../../../appsettings_global.json";
if (File.Exists(relative_path)) {
IConfigurationRoot global_config = new ConfigurationBuilder().AddJsonFile(relative_path, false, true).Build();
global_settings = global_config.GetRequiredSection("Settings").Get<GLOBAL_SETTINGS>();
}
2
Answers
i found that the following will do what i need; i.e., convert the relative path to an absolute. if there are other/better answers, please do post them.
picture1
according to the picture1 the file path should be "test/appsettings_global.json"
And make sure appsettings_global.json file is selected "Copy if newer" or "Copy always" under properties > Copy to Output Directory of the file