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
の作成について考えていたが、それはメモリの非常に効率的に使用するように見えるしていません。私はもっときれいな方法があることを望んでいた。