I am trying to get a notification if a file is created, copied or moved to the directory that I am viewing. I want only to receive notifications about files, but not about directories.
Here is the code I currently have:
_watcher.NotifyFilter = NotifyFilters.FileName;
_watcher.Created += new FileSystemEventHandler(file_created);
_watcher.Changed += new FileSystemEventHandler(file_created);
_watcher.Renamed += new RenamedEventHandler(file_created);
_watcher.IncludeSubdirectories = true;
_watcher.EnableRaisingEvents = true;
The problem is that if I move the directory containing the file in it, I do not receive any events for this file.
How can I get it to notify me of all added files (no matter how) to the watched directory or its subdirectories?
Incase I haven’t explained enough ... I have WatchedDirectory and Directory1. Directory1 contains Hello.txt. If I translate Directory1 to WatchedDirectory, I want to receive a notification for Hello.txt.
The EDIT: . I should note that my OS is Windows 8. And I get a notification about copy / paste events, but I do not move events (drag and drop to a folder).
source
share