I have a method in my service where I'm watching the services config file. It looks like this:
private void WatchConfigurationFile()
{
var fileLocation = Assembly.GetExecutingAssembly().Location;
watcher.Path = Path.GetDirectoryName(fileLocation);
watcher.NotifyFilter = NotifyFilters.LastWrite;
watcher.Filter = fileLocation + ".config";
watcher.Changed += new FileSystemEventHandler(OnConfigChange);
watcher.EnableRaisingEvents = true;
Log.DebugFormat("config location: {0}", watcher.Filter.ToString());
}
The log returns the complete file path location of my targeted file, including the location of where it is stored: C/Users etc etc
Yet, when I update my config file, the changes aren't displayed in my log files. The logging is done like this:
private void OnConfigChange(object source, FileSystemEventArgs e)
{
ConfigurationManager.RefreshSection("appSettings");
Log.DebugFormat("Updated ConnectionString: {0}", ConfigurationManager.AppSettings["dbConn"]);
}
However in my file watcher class, if I change the filter to the actual name of the file, which in my case is the service exe name with a '.config' at the end. It works fine.
Why is it one works and the other doesn't?