2008-11-06, 10:36 PM
I want to automatically reload the user settings file when a user makes a change to prevent them having to restart the dvbt radio service. Code as follows...Log file entries...At first I thought it might be receiving an event for the folder AND one for the file which is why I got it to log e.FullPath but it's two events just for the file. I'm simply opening the file in Notepad (before starting the service) then making a change and saving without closing.
Any ideas?
Cheers,
Brian
Code:
private static DvbtrUserSettings UserSettings;
private FileSystemWatcher UserSettingsFileWatcher;
Code:
UserSettings = new DvbtrUserSettings(GBInstallDir + @"plugins\DVB-T Radio\DVBTRadio.xml");
UserSettingsFileWatcher = new FileSystemWatcher(GBInstallDir + @"plugins\DVB-T Radio", "DVBTRadio.xml");
UserSettingsFileWatcher.NotifyFilter = NotifyFilters.LastWrite;
UserSettingsFileWatcher.Changed += new FileSystemEventHandler(UserSettingsFileWatcher_Changed);
UserSettingsFileWatcher.EnableRaisingEvents = true;
Code:
void UserSettingsFileWatcher_Changed(object sender, FileSystemEventArgs e)
{
Log.WriteLine("FileWatcher_Changed event received: " + e.FullPath);
if (e.ChangeType == WatcherChangeTypes.Changed)
{
Log.WriteLine("UserSettings file change. Reloading...");
UserSettings.Load();
Log.WriteLine("UserSettings: ");
// Cut for brevity
}
}
Code:
06/11/2008 22:14:00.452 FileWatcher_Changed event received: C:\Program Files\Devnz\GBPVR\plugins\DVB-T Radio\DVBTRadio.xml
06/11/2008 22:14:00.452 UserSettings file change. Reloading...
06/11/2008 22:14:00.467 UserSettings:
06/11/2008 22:14:00.467 AudioDecoderName:
06/11/2008 22:14:00.467 DisableScreenSaver: False
06/11/2008 22:14:00.467 EnableGetNowNext: True
06/11/2008 22:14:00.467 ONID: -1
06/11/2008 22:14:00.467 PlaybackBufferDelay: 500
06/11/2008 22:14:00.467 ScanFullEPG: True
06/11/2008 22:14:00.467 StopOnChannelChange: False
06/11/2008 22:14:00.467 UseLivePlayback: True
06/11/2008 22:14:00.467 FileWatcher_Changed event received: C:\Program Files\Devnz\GBPVR\plugins\DVB-T Radio\DVBTRadio.xml
06/11/2008 22:14:00.467 UserSettings file change. Reloading...
06/11/2008 22:14:00.483 UserSettings:
06/11/2008 22:14:00.483 AudioDecoderName:
06/11/2008 22:14:00.483 DisableScreenSaver: False
06/11/2008 22:14:00.483 EnableGetNowNext: True
06/11/2008 22:14:00.483 ONID: -1
06/11/2008 22:14:00.483 PlaybackBufferDelay: 500
06/11/2008 22:14:00.483 ScanFullEPG: True
06/11/2008 22:14:00.483 StopOnChannelChange: False
06/11/2008 22:14:00.483 UseLivePlayback: True
Any ideas?
Cheers,
Brian