I have a directory structure like the following where csv files may be added to any of the sub-directories. (The business logic is that order files firstly will be save under "Vendor" folder, and after being checked, they will be moved to "Processed" folders.)
I want to only monitor folders called "Processed". For example, if there are files added to "Processed" folder, I would like to get notified and do something in the callback methods. If files are added under "Vendor" folder, I want to ignore them. How should I configure FileSystemWatcher to achieve this?
This is what I've got now.
public static void Watch()
{
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = path; //here is the path of the "Order" folder;
watcher.Created += FileSystemWatcher_Created;
watcher.EnableRaisingEvents = true;
}
private static void FileSystemWatcher_Created(object source, FileSystemEventArgs e)
{
//do something when there are new files added to the watched directory
}
