![.NET]()
File System Watcher helps you to monitor file changes on a disk or local network drive.
It can be used on console apps that react to changes according to the files copied, deleted, changed, or created.
I prepared a sample monitoring the OneDrive default user folder to observe PDF files.
Create a console app using
Add the code below to Program.cs, and you will start monitoring the OneDrive folder on Windows machines.
Inside the events, you can do whatever you need with the files.
To prevent the app from starting more than once, create a Mutex to prevent several instances from running at the same time. You need to create a unique name for your application, replacing UniqueApplicationName.
You can hide the console screen to avoid the use of terminating the application, and add the code below to the top of the Program.cs.
Conclusion
You can create logs or process files that have been modified, created, deleted, or changed; it's up to you and your requirements to monitor file changes on the hard drive.
Use this resource wisely.
The complete documentation is here.