File system monitoring
As systems programmers, we must find ways to communicate with our apps. After all, there is no user interface wherein the user can indicate their desired actions.
Most apps in that category listen to network ports or have other ways for systems to communicate with them. One of those ways is to wait for changes in files or directories.
Keeping an eye on files or folders is a fairly common scenario. For instance, we could build a system that processes the files that we get through an email system. As soon as a file is delivered as an attachment, the mail client places it in a directory and our system picks it up.
This means that we need to have a way to keep an eye on that folder. Luckily, that is not too hard to do. It does require some explanation, so let me walk you through it.
We will begin with the class that other classes interact with:
internal class MyFolderWatcher : Idisposable { protected virtual void Dispose(bool...