vikram
vikram

Reputation: 11

FindFirstChangeNotification API

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.

Upvotes: 1

Views: 2318

Answers (2)

user337598
user337598

Reputation:

Use ReadDirectoryChanges(), it monitors files in a directory tree. ReadDirectoryChanges is basically doing the same thing as FindFirstChangeNotification, FindNextChangeNotification. ReadDirectoryChanges is just more powerful 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.

Upvotes: 1

Alex K.
Alex K.

Reputation: 175916

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.

Upvotes: 1

Related Questions