I have a FileSystemWatcher that I would like to run an OnCreated event for each folder copied to the directory Iโve viewed . Several folders will be copied to this browsing directory manually again.
Currently, it fires only event for the copied first folder.
Therefore, if I look at folder X and select folders A, B, C in Windows Explorer and copy them to X, OnCreated starts for A, but not B or C.
This is my code that I use to configure FileSystemWatcher :
watcher = new System.IO.FileSystemWatcher(watchPath); watcher.InternalBufferSize = 32768; watcher.IncludeSubdirectories = true; watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.CreationTime | NotifyFilters.LastWrite; watcher.Changed += new FileSystemEventHandler(OnChanged); watcher.Created += new FileSystemEventHandler(OnCreated); watcher.EnableRaisingEvents = true;
and here is my OnCeated method
void OnCeated(object sender, FileSystemEventArgs e) { XDocument xmlDoc = BeginImport(e.FullPath); }
Any idea why this only fires the event for the first folder copied to the watched directory?
ELG source share