The FileSystemWatcher is responsible for to track the updates of either file or folder/sub-folders, Suppose if I would like to continuously monitor a folder , something like what are the newly added files or something like what are deleted files or which files are renamed such operations.
It’s not easy task to monitor a folder with old approach creates a service and use the Threading to continuously monitoring the folder. But with this approach needs more CPU and memory attention.
But with The FileSystemWatcher it’s quite easy.
We have one more advantage, Consider the below scenario. I have 2 applications
1. Quoting application QA(Core Operations) only providing services to others it does not have any other information of any other applications.
2. Broker application BA(it communicate with other applications by using services)
I have one functionality if user requested quoting from the Broker application and then request ends, user don’t wait till the Quoting application response, it’s like one way communication, after the Quoting application service process all the requests done by broker application and responds appropriately , then how does Broker applications come to know which requests are done?
Approach 1: Call the BA services after QA completed the request. But with this approach QA doesn’t have any other application service end points. So in this way it won’t work out.
Approach 2: After process the BA request then create a xml file with request information and save it to some shared folder
And run the Windows service with File watcher service option and point out the folder path to the Shared folder path, Now handle the Created event and call the BA services accordingly to track the requested information.