FileSystemWatcher keeping parent directory
- by Henry Jackson
I am using FileSystemWatcher to monitor a folder, and it seems to be preventing the folder's parent from being deleted.
For example, I have the file structure:
C:\Root\FolderToWatch\...
with the FileSystemWatcher targeting FolderToWatch. While my program is running, if I go to Windows Explorer and try to delete Root, I get an error "Cannot delete Root: access is denied".
However, if I delete FolderToWatch FIRST, I can then delete Root without incident. (Needless to say, if the FileSystemWatcher is not enabled, I have no problem deleting either folder.)
What gives? Why does the FileSystemWatcher hang onto it's target's parent like that?
How (if possible) can I stop this behavior? I would like the user to be able to freely move or delete directories in Windows Explorer.