I am using FileSystemWatcher to monitor newly added files in several folders. FileSystemWatcher is created for N number of folders/directories to watch separately. It works fine at the start but after some time it doesn't raise any events. Am I missing something here? Any inputs/help is much appreciated.
// Set up FileSystemWatchers for the specific subdirectories.
foreach (string subdirectory in subdirectoriesToWatch)
{
string subdirectoryPath = Path.Combine(rootDirectory, subdirectory);
FileSystemWatcher subdirectoryWatcher = CreateWatcher(subdirectoryPath, true);
subdirectoryWatcher.Created += (sender, e) =>
{
Console.WriteLine($"File created in {subdirectory}: {e.Name}");
};
}
I have increased the InternalBufferSize as well and it's going to filter the properties as well by based on file mask provided.