Programming Tips - How can my program efficiently detect when files in a
Q. How can my program efficiently detect when files in a
folder have changed?
A. On Linux/Unix the answer is FAM (File Alteration Monitor).
More info here:
On Linux, inotify has replaced FAM:
(Do "man inotify" for info)
These have a rather nice interface. You open a folder
and wait on a read. You get data when a change occurs.
Eventually, close the handle. Its like reading a stream.
My only complaint is that, at least in my last try, they
could not monitor a tree.
On Windows, use FindFirstChangeNotification()
Its API is more painful.
Windows now has ReadDirectoryChanges and FileSystemWatcher.