I am using FindFirstChangeNotification API to monitor the changes happening in a particular folder.But how to exclude a particular file(present in the watching folder) change notification Only.
It works at the directory level, if you want to exclude a specific file then just ignore any notifications about it in you application logic.
I believe we can use ReadDirectoryChangesW Function to know the information that describes the changes within the specified directory,can you please provide me a sample which uses FindFirstChangeNotification to monitor a directory and ReadDirectoryChangesW to describes the changes.
Use ReadDirectoryChanges(), it monitors files in a directory tree. ReadDirectoryChangesis basically doing the same thing as FindFirstChangeNotification/FindNextChangeNotification, ReadDirectoryChanges is just more powerfull because if you provide the optional callback function to ReadDirectoryChangesW(), you can see which file changed, and why it changed, and then filter in your application logic without overhead of any system call(s) to find which file changed, ...you get this array of structures.
typedef struct _FILE_NOTIFY_INFORMATION {
DWORD NextEntryOffset;
DWORD Action; // <- reason for the change
DWORD FileNameLength;
WCHAR FileName[1];
} FILE_NOTIFY_INFORMATION, *PFILE_NOTIFY_INFORMATION;
FindNextChangeNotification is more like a sledgehammer, you still need to check the folder to see what exactly changed, but it easier to use if you already know which file to hunt for. Findfirst/Next also slightly easier to use in terms of thread waiting/IO completion logic.