Is there anything like inotify on Windows?

johansson picture johansson · Aug 19, 2010 · Viewed 48.5k times · Source

With the Linux OS, there is the ionotify subsystem which notifies an application of changes to the filesystem.

However, I am mainly a Windows user, so I was wondering if there is a similar way to monitor filesystem changes?

Answer

blucz picture blucz · Aug 19, 2010

If you're using .net, use FileSystemWatcher. More info here: http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx

If you're using C, use FindFirstChangeNotification, FindNextChangeNotification, ReadDirectoryChangesW. More info here: http://msdn.microsoft.com/en-us/library/aa365261(VS.85).aspx

On OSX, the relevant api is the fsevents api.

They're all subtly different from one another, and they all have questionable reliability in edge cases. In general, you can't depend on these apis for a complete view of all changes 100% of the time. Most people using file system monitoring combine it with periodic scans to compensate for lost or incomplete information from the push api.