Is there anything like inotify on Windows?

WindowsInotify

Windows 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

Solution 4 - Windows

JNotify or FileMon from Microsoft.

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.

Solution 8 - Windows

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjohanssonView Question on Stackoverflow
Solution 1 - WindowsbluczView Answer on Stackoverflow
Solution 2 - WindowsnosView Answer on Stackoverflow
Solution 3 - WindowsRemo HarsonoView Answer on Stackoverflow
Solution 4 - WindowsEugeneView Answer on Stackoverflow
Solution 5 - WindowsPeter KrnjevicView Answer on Stackoverflow
Solution 6 - WindowsPhillip Brandon HolmesView Answer on Stackoverflow
Solution 7 - WindowsPharaunView Answer on Stackoverflow
Solution 8 - WindowslifeiView Answer on Stackoverflow