Everywhere I find these two lines of code used to set filter for file system watcher in samples provided..
FileSystemWatcher watcher = new FileSystemWatcher(
You can't do that. The Filter property only supports one filter at a time. From the documentation:
Use of multiple filters such as
*.txt|*.docis not supported.
You need to create a FileSystemWatcher for each file type. You can then bind them all to the same set of FileSystemEventHandler:
string[] filters = { "*.txt", "*.doc", "*.docx", "*.xls", "*.xlsx" };
List watchers = new List();
foreach(string f in filters)
{
FileSystemWatcher w = new FileSystemWatcher();
w.Filter = f;
w.Changed += MyChangedHandler;
watchers.Add(w);
}