When using FileSystemWatcher and setting the watcher.IncludeSubdirectories = true
.
I am only able to capture changes to subdirectories two levels down (e.g Dir/SubDir1/SubDir2
). But if I want something past that directory (e.g. Dir/SubDir1/SubDir2/.../...
) no event will be raised.
I maxed out the InternalBufferSize = 65536
. Is there a way to be able to get in deeper nested subfolders?
This is to be ran and tested on a network drive folder:
using (FileSystemWatcher _watcher = new FileSystemWatcher())
{
_watcher.Path = directory;
_watcher.IncludeSubdirectories = true;
_watcher.NotifyFilter = NotifyFilters.LastWrite
| NotifyFilters.FileName
| NotifyFilters.DirectoryName;
_watcher.Changed += new FileSystemEventHandler(Program._watcher_Changed);
_watcher.Created += new FileSystemEventHandler(Program._watcher_Changed);
_watcher.Deleted += new FileSystemEventHandler(Program._watcher_Changed);
_watcher.Renamed += new RenamedEventHandler(Program._watcher_Renamed);
_watcher.Filter = "*.*";
_watcher.InternalBufferSize = 65536;
_watcher.EnableRaisingEvents = true;
Console.WriteLine("Press 'q' to quit the sample.");
while (Console.Read() != 'q');
}