For example, there is a program with some app.config where the path for downloading files is stored.
Can the program understand when it is running that the config has been edited and based on this, download to another folder?
Yes maybe.
First you need to explicitly upload your settings file:
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal); Next you need to get a list of files from which this settings file was compiled:
var files = config.Locations.Cast<ConfigurationLocation>().Select(loc => loc.Path); Now you can start monitoring these files:
var monitor = new HostFileChangeMonitor(files.ToArray()); monitor.NotifyOnChanged(_ => { // ... }); When the signal about changing files arrives, you must wait 100-200 milliseconds and do everything from the beginning.
HostFileChangeMonitor better than traditional FileSystemWatcher ? - VladDSource: https://ru.stackoverflow.com/questions/567707/
All Articles
ReadDirectoryChangesAPI function or its equivalent in .Net. - ߊߚߤߘ