With the Linux OS, there is the inotify 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?
With the Linux OS, there is the inotify 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?
See the FindFirstChangeNotification API, or the .NET counterpart FileSystemWatcher
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.
See the FindFirstChangeNotification API, or the .NET counterpart FileSystemWatcher
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.
FileSystemWatcher
|FindFirstChangeNotification
PhillipBrandonHolmes was speaking of? –
Canova 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().
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.
© 2022 - 2024 — McMap. All rights reserved.