Everywhere I find these two lines of code used to set filter for file system watcher in samples provided..
FileSystemWatcher watcher = new FileSystemWatcher(
Since .Net Core 3.x and .Net 5 Preview you can simply add multiple filters to the Filters collection.
var watcher = new FileSystemWatcher();
watcher.Path = "/your/path";
watcher.Filters.Add("*.yml");
watcher.Filters.Add("*.yaml");
watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName;
watcher.EnableRaisingEvents = true;
Alternatively if you like object initializers,
var watcher = new FileSystemWatcher
{
Path = "/your/path",
Filters = {"*.yml", "*.yaml"},
NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName,
EnableRaisingEvents = true,
};