File Create/Update Notification
-
Hi I'm working on a fairly large file indexing system, and I'm trying to find the best and fastest way of finding out if a file needs reindexing. Currently the best we've got is keeping a DB of the last time a file was indexed and periodically rescanning a checking the last modifed date against that. Is there a way of being told if a file has been created or modified, in a similar sort of way to Visual Studio bringing up the "This file has been modified outside of Visual Studio..." dialog? (One which doesn't require a lot of resources as well - this is intended to run in the background) Cheers Dave
-
Hi I'm working on a fairly large file indexing system, and I'm trying to find the best and fastest way of finding out if a file needs reindexing. Currently the best we've got is keeping a DB of the last time a file was indexed and periodically rescanning a checking the last modifed date against that. Is there a way of being told if a file has been created or modified, in a similar sort of way to Visual Studio bringing up the "This file has been modified outside of Visual Studio..." dialog? (One which doesn't require a lot of resources as well - this is intended to run in the background) Cheers Dave
Check out 'FindFirstChangeNotification' in the Win32 documentation. Paul
-
Check out 'FindFirstChangeNotification' in the Win32 documentation. Paul
Cheers Paul It's always the problem with trying to find where to start looking! :) Dave
-
Cheers Paul It's always the problem with trying to find where to start looking! :) Dave
you can look here also: UINT ThreadNotifyFunc (LPVOID pParam) { HWND hwnd = (HWND) pParam; // Window to notify HANDLE hChange = ::FindFirstChangeNotification (_T ("C:\\"), TRUE, FILE_NOTIFY_CHANGE_FILE_NAME ¦ FILE_NOTIFY_CHANGE_DIR_NAME); if (hChange == INVALID_HANDLE_VALUE) { TRACE (_T ("Error: FindFirstChangeNotification failed\n")); return (UINT) -1; } while (...) { ::WaitForSingleObject (hChange, INFINITE); ::PostMessage (hwnd, WM_USER_CHANGE_NOTIFY, 0, 2); ::FindNextChangeNotification (hChange); // Reset } ::FindCloseChangeNotification (hChange); return 0; }
It's not a bug, it's an undocumented feature.
suhredayan@omniquad.commessenger :suhredayan@hotmail.com
-
Cheers Paul It's always the problem with trying to find where to start looking! :) Dave
Also look for
ReadDirectoryChangesW()
.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)