The ‘FileSystemWatcher’ class is very useful when it comes to monitor a file system path for changes such as create, update and delete of directories/files.
Create an object from the FileSystemWatcher class. (You need to add the ‘System.IO’ namespace)
And set the following properties. For this example we will only consider about text files (.txt)
And add the following event handlers and create events.
And create the following events
Execute this and create, change, rename and delete a text file. And above mentioned events will be invoked.