Is there anything like inotify on Windows?
WindowsInotifyWindows Problem Overview
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?
Windows Solutions
Solution 1 - Windows
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.
Solution 2 - Windows
See the FindFirstChangeNotification API, or the .NET counterpart FileSystemWatcher
Solution 3 - Windows
take a look at this: inotify-win, a port of the inotifywait tool for Windows
and also this: inotify-tools
Solution 4 - Windows
Solution 5 - Windows
A bit late but ...
Windows has a facility similar to OSX events whereby you can monitor events without running an app. The Windows USN Journal keeps track of all file changes. Jeffrey Richter (author of Advanced Windows) wrote a terrific article with working samples for MSDN Journal. Update: article now from archive.org since MSJ no longer online at MS.
MSDN documentation for USN Change Journals.
USN Change Journals are probably better if you're building applications like backup tools or indexes that need to monitor entire volumes.
Solution 6 - Windows
FileSystemWatcher() is unreliable mainly due to the fact it's error handling for the watcher buffer is more or less incomplete. Due to a lack of path and detailed error handling information, Microsoft gives you no way to recover or manually poll the working directory.
The JNotify for Windows is unreliable as well because this bug ^ derives from win32. JNotify uses win32. So, it's no different than FileSystemWatcher().
Solution 7 - Windows
I did a bit of searching, I seem to recall seeing something similar for Windows. There's FileSystemWatcher for .NET. Its mainly for NT or XP and forward.