FileSystemWatcher
을 만들 때 볼 수있는 NotifyFilters
을 선택할 수있는 옵션이 있습니다. 그러나 내 이해를 위해 또는 NotifyFilters.Attributes
과 같이 FileSystemWatcher.Changed
이벤트를 트리거 할 수있는 복수 NotifyFilters
이 있습니다.어떤 NotifyFilter가 FileSystemWatcher.Changed를 트리거 했습니까?
코드 :
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = Path.GetDirectoryName(PATH);
watcher.Filter = Path.GetFileName(PATH);
watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size | NotifyFilters.FileName | NotifyFilters.Security |
NotifyFilters.CreationTime | NotifyFilters.Attributes | NotifyFilters.LastAccess | NotifyFilters.DirectoryName;
watcher.Changed += OnFileSystemWatcher_Changed;
watcher.Deleted += OnFileSystemWatcher_Deleted;
watcher.Created += OnFileSystemWatcher_Created;
watcher.Renamed += OnFileSystemWatcher_Renamed;
private void OnFileSystemWatcher_Changed(object sender, FileSystemEventArgs e)
{
// Do Stuff
}
문제 : FileSystemWatcher.Changed
이벤트에 대한 내 이벤트 처리기에서, 이벤트를 발생하는 NotifyFilter
결정하는 방법이?
시도 : 난 그냥 NotifyFilter
의 각 유형에 대한 새로운 FileSystemWatcher
을 만드는 방법에 대해 생각했다,하지만 메모리의 매우 효율적인 사용은 아닌 것 같아. 나는 더 깨끗한 방법이 있기를 바랬습니다.