I have a FileSystemWatcher
that I would like to fire an OnCreated event
for every folder copied into the watched directory. Several folders will be copied into this watched directory at once, manually.
Currently it is only firing the event
for the first folder copied.
So if I'm watching folder X and select folders A,B,C in windows explorer and copy them into X, OnCreated
is fired for A but not B or C.
This is my code that I'm using to set up the 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 is only firing the event for the first folder copied into the watched directory?