I have some problems with this but I finally find an answer.
When config file looks like this:
<configuration>
<appSettings file="appsettings.config"/>
</configuration>
The code above is working correctly:
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var file = config.AppSettings.File;
But when config file is (it works same as above but syntax is different):
<configuration>
<appSettings configSource="appsettings.config"/> <!-- configSource instead of file -->
</configuration>
I have to use following:
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var file = config.AppSettings.SectionInformation.ConfigSource;
So I have to check if config.AppSettings.SectionInformation.ConfigSource
and config.AppSettings.File
is not an empty string and monitor correct one.