我会保持原始XML的副本,然后运行时,FileSystemWatcher的触发比较XML节点(S)。有关比较XML节点的建议,请参阅Efficient algorithm for comparing XML nodes。
文件守望例如
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;
...
如何读取XML配置?你使用XPath还是你有一些你想要序列化/反序列化为XML的Settings类? –
它是简单的xml文件,我使用Linq到XML – tito11