Search code examples
c#file-watcher

When watching a network drive "Created" is not fired when the file comes from another drive


I have a FileWatcher that works fine on local and network drives. On certain network drives there is a problem when the file comes from another network drive. Then the "Created" event is not fired. The UNC paths and read/write permissions are correct. I can open, edit, save, copy or delete the file with the application. The "changed" and "deleted" events fires when i process the file.

watcher = new FileSystemWatcher();
watcher.Path = source;
watcher.NotifyFilter = NotifyFilters.FileName;
watcher.Filter = searchPattern;
watcher.EnableRaisingEvents = true;
watcher.Created += new FileSystemEventHandler(OnCreate);
watcher.Deleted += new FileSystemEventHandler(OnDelete);
watcher.Changed += new FileSystemEventHandler(OnChange);

Solution

  • The Renamed event did the trick. I am not sure if the drive is already being watched, because i am not the owner of the share. Other Shares on the same drive are firing "Created".

    Many thanks