Ever need to know when the contents of a folder have changed? Using the FindFirstChangeNotification and FindNextChangeNotification functions you can have Windows alert your application whenever a folder or any of its sub-folders change. Changes detected include copying, deleting, renaming files as well as changing the size or attributes of any files in the folder or in any sub folders!
Download Zip ✦✦✦ https://t.co/u3zeGaR9cV
This sample also shows how to suspend your application's processing until multiple events have occurred. In this case I wait for a folder to change or a program to terminate. The WaitForMultipleObjects function makes this possible.
This VB6 program uses the FileSystemObject from the Microsoft Scripting Runtime Engine (Scrrun.dll) to display the number of files in a folder. Scrrun.dll comes with VB6 and Windows 98 or later (see my Using the FileSystemObject sample for more info).
The Folder Spy program detects changes occurring in a folder by calling the FindFirstChangeNotification API.. Then using the WaitForSingleObject function it waits until Windows notifies it that a change has occurred. The advantage of using WaitForSingleObject is that the program enters a very efficient wait state (it consumes very little CPU resources) until notified of a change.
WaitForSingleObject lets you specify the amount of time to wait. It can be infinite or a relatively long period. The down side is that the program is completely frozen and will not respond to mouse events until the folder changes. If no changes occur, the program will be frozen forever! See my Wait for Process to Terminate example for more info.
To overcome this the wait function is placed in a loop and the time interval is set to a small value. When the function completes its return code is tested. If it returned because the object being waited for was signaled (i.e. the folder changed) the loop terminates. Otherwise a DoEvents is issued so the program can react to mouse or other events and the wait function is re-executed.
Okay, I lied. I don't use WaitForSingleObject. I use WaitForMultipleObjects lets you wait for more than one thing. When the program starts spying it launches a small executable ("Stop Spy" shown on the left in the above picture). The Stop Spying executable does nothing except display a button that terminates it when clicked. WaitForMultipleObjects lets Folder Spy wait until either Stop Spy ends or the folder changes. Since Stop Spy runs separately from the main program it is not effected by the wait function and is always responsive to mouse events. When WaitForMultipleObjects terminates its return code is checked. If it returned because the folder changed, a message is displayed.
What happens to the Stop Spy executable when you click the Quit button? It gets terminated. Briefly, to kill it all top level windows are enumerated to create a list of those owned by the process whose ID matches that of the Stop Spy executable. Then a WM_CLOSE message is sent to those windows causing the .exe to end. This is discussed further in my Safely Stop a Running Process example.
Open Explorer and navigate to the folder you are spying on. Arrange Explorer and FolderSpy so both programs are visible. Make changes to the folder by copying or deleting a file or by changing the attributes for a file (right click the file and select properties). As soon as a change is made, FolderSpy will alert you with a message.
Try clicking the "Stop Spying" or "Quit" buttons and you will see that FolderSpy does not react until the wait period expires. Experiment with different wait periods in function fWaitForChange to see the effect.
Now run Folder Spy again and click the "Stop Spying on Folder" button on the Stop Spying form. You will see that this causes FolderSpy to immediately stop waiting and start responding to your input again.
These software will notify you whenever any change is detected in a particular drive, folder, sub-folders, and files. For example, if a file is renamed, content is changed, folder is moved or deleted, etc., you will get the alert. A log report of changes is also generated that you can use for later analysis.
Most of these software also provide the feature to automatically execute an application whenever changes occur. A lot of changes happen in folders that you might want to monitor. Moreover, when you leave your PC unattended and someone else performs any changes, these software will come in handy to track those changes.
(adsbygoogle = window.adsbygoogle []).push(); TheFolderSpy is one of the best software in this list to silently monitor configured folders or drives for changes. When any change is detected, it can automatically send an email to configured email address. Make sure your Internet connection is active at that moment. Apart from this, it also shows changed type, file/folder name, and time when the changes were detected.
You can use this software to monitor multiple folders together, which makes it handy. Moreover, you can also select custom location to save the log report as text file. While adding an item in monitoring list, you can set detection types for changes: Deleted, Renamed, Created, and Changed. Along with this, you can enable the option to send email, and configure which email addresses should be used to send and receive email. After this, you need to restart the application and save the items for later use.
Directory Monitor is another handy software that lets you add multiple directories to monitor for changes. With every selected directory, you can include sub-folders, files, and it will start monitoring all directories. You can also add filters to monitor only specific file types. Whenever your files or folders are deleted, renamed, modified, or new items are added, it will show those changes on its interface in real-time.
Apart from this, it will also show system tray notification to catch your attention that a particular change has been made to your files or folders. Moreover, you can also set an application (exe, bat, com, or cmd) to execute automatically when changes are detected. Unfortunately, option to send an email alert is available in paid version of this software, but you can use other command-line email senders to get an email whenever something changes. One very useful feature of this software is that it generates log file as plain text file and also stores activity log. It is available in both installer and portable version.
Watch 4 Folder (unregistered version) is also a good software and lets you monitor one directory at a time. Whenever any change is detected in monitored directory, it will show you desktop alert. Apart from this, it also shows information in a small window to check what changed and in which file/folder, including the time.
While adding a folder in the watch list, you can include sub-folders. Apart from this, it also lets you select events to monitor: file delete, free space change, folder rename, media insert and remove, folder change, folder create, etc. Moreover, you can also set an application to launch when the change is noticed. So, multiple features are available in this handy folder monitoring software.
Different color labels are used for removed entry, file, and directory. This will help you easily check the type in which changes are made. There are no extra features, but it successfully serves the purpose of monitoring a folder or drive.
In this article, I have covered from simple to feature-rich folder monitoring software. All these are handy to perform the main task. However, TheFolderSpy software is the clear winner in this list. I really liked its feature of sending the email notification to desired email address.
795a8134c1