Is there a way to see what exactly changed when OnChanged is called? I am trying to filter out file attribute changes.
3 Answers
The method provides an argument of type FileSystemEventArgs
, which supplies data on the type and path of the change.
You can use this to filter only the WatcherChangeTypes.Changed
value, which is:
The change of a file or folder. The types of changes include: changes to size, attributes, security settings, last write, and last access time.
See @Oliver's answer for the supplemental info to this answer, I was just about to add that :)

- 21,452
- 6
- 62
- 109
You can use NotifyFilter property to specify what kind of change you want to observe. As Rotem already stated the FileSystemEventArgs
class also provides some information of a change.

- 1,507
- 1
- 12
- 23
I don't think you can filter out anything as granular as which attributes were changed. You can use the NotifyFilters
property to specify that you only want to raise events when file attributes were changed. The event is raised when each change happens so you can in response to the event simply create a FileInfo
class with the provided path of the file and inspect the new attributes.

- 11,292
- 11
- 63
- 102