Search code examples
filewinapihookappearance

Is there anyway to know that in some folder some file just got created or deleted?


I thinking about some global hook, but googling for "file create hook" gave me nothing.

I doing folder explorer in my prog... and I would like to add / remove files from visual representation in my prog as soon as they got added / deleted / appeared (for network folders), instead of running loop to scan the folder all the time.

Is that possible? I hope for some WinAPI solution.


Solution

  • You can use ReadDirectoryChangesW which notifies you of changes in a specific directory.

    Also you can use SHChangeNotifyRegister, which is a shell feature and also works for "shell" forlders..

    I suggest to read the following article: Understanding ReadDirectoryChangesW - Part 1