Xi Vix
Xi Vix

Reputation: 1361

c# detect directory change

I use FileSystemWatcher in C# to monitor a directory. It is well documented (and well complained about) that FileSystemWatcher works fine to detect changes in the directory, but not changes to the directory. To get around that I am checking directory existence every second but what a waste. I need to know if something changes in the directory and if the directory is deleted or renamed. Is there a better way without polling?

Upvotes: 1

Views: 637

Answers (1)

ivan
ivan

Reputation: 628

You could monitor parent directory AND set Filter property to your folder's name to get only events for the folder AND set IncludeSubdirectories to true.

Upvotes: 3

Related Questions