2

in my Solution i have two projects (Windows Service and WPF to mange the service) and i have a sitting file (XML) that service use What i ask about is :

i want to know when the user make any change in the XML file with out restart the service and know What is the xml node(s) that has changed

I have searched a lot and found that the solution is through FileSystemWatcher

Listens to the file system change notifications and raises events when a directory, or file in a directory, changes.

but how i know What is the xml node(s) that has changed

thanks

Tarek Saied
  • 6,482
  • 20
  • 67
  • 111

1 Answers1

0

I would keep a copy of the original XML and then run a compare when the FileSystemWatcher triggers. Have a look at Efficient algorithm for comparing XML nodes for a suggestion on comparing XML nodes.

File watcher example

String folderLocation = System.Configuration.ConfigurationManager.AppSettings["FOLDER_LOCATION"].ToString();

            _watcher = new System.IO.FileSystemWatcher();
            _watcher.Path = folderLocation;
            _watcher.IncludeSubdirectories = false;
            _watcher.NotifyFilter = NotifyFilters.Size;
            _watcher.Changed += new FileSystemEventHandler(OnFileChanged);
            _watcher.EnableRaisingEvents = true;

private void OnFileChanged(object sender, FileSystemEventArgs e)
        {
            String file = e.FullPath;
...
Community
  • 1
  • 1
BigBadOwl
  • 669
  • 2
  • 9
  • 22