다음 방법을 사용하여 FileSystemEventHandler를 설정하여 config.xml 파일의 변경 사항을 모니터링합니다.FileSystemEventHandler 메서드를 매개 변수로 사용
public void WatchConfigFile(???)
{
this.watcher = new FileSystemWatcher();
DirectoryInfo _di = Directory.GetParent(configFile);
this.watcher.Path = _di.FullName;
this.watcher.Filter = Path.GetFileName(configFile);
this.watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.CreationTime;
this.watcher.Changed += new FileSystemEventHandler(???);
this.watcher.EnableRaisingEvents = true;
log.Info("Config watcher established at " + watcher.Path);
}
나는 우리가 반복해서 사용하지만 방법으로는 onChanged 방법 핸들러를 전달하고 감시자에 할당하는 방법을 모른다 표준 방법의 라이브러리에이 방법을 추가하고 싶습니다. ???로 표현되는 방법 이 같은 것 (변경 사항을 처리하기 위해) :
public void ConfigFileChanged(object source, FileSystemEventArgs e)
{
// Do something when file is updated
}
나는대로이를 호출 할 수 싶습니다 것은 다음과 그냥 같이 핸들러 자체를 원하는처럼
_library.WatchConfigFile(ConfgiFileChanged);
감사합니다! 나는 그것을 필요 이상으로 어렵게 만들고 있었다. 또한 List와 같은 아이디어. –
BrianKE