readdirectorychangesw

How to keep ReadDirectoryChangesW from missing file changes

There are many posts on the internet about the ReadDirectoryChangesW API function missing files when there is a lot of file activity. Most blame the speed at which the ReadDirectoryChangesW function loop is called. This is an incorrect assumption. The best explanation I have seen is in the following post, the comment on Monday, April ...

Can I get the file info which changes in a specified directory using FindFirstChangeNotification and FindNextChangeNofication instead of ReadDirectoryChangesW?

I want to monitor upon a specified directory and if there's any file or subdirectory changes, I can be notified. I realize the function with the following simple code segment: UINT myThreadFunc(LPVOID pParam) { int changeCount = 0; while(true) { HANDLE changeHandle = FindFirstChangeNotification(L"C:\\", TRUE, FILE_NOTIFY_CHANGE_...

How to use ReadDirectoryChangesW() method with completion routine?

I want to use function ReadDirectoryChangesW() in asynchronous mode with I/O completion routine supplied. The question is I don't know how to retrieve the exact information about the change in the completion routine (a CALLBACK function). Completion routine is defined like this: VOID CALLBACK FileIOCompletionRoutine( [in] ...

Thread deadlock when using ReadDirectoryChangesW asynchronously

I want to monitor in real-time the changes of several directories in one thread, so I decided to use ReadDirectoryChangesW() method asynchronously with GetQueuedCompletionStatus. Here is my code: static DWORD WINAPI Routine( LPVOID lParam ) { FileSystemWatcher* obj = (FileSystemWatcher*)lParam; obj->hDir[0] = CreateFile( ...

Why is my ReadDirectoryChangesW not picking up changed files?

I'm sure I am just doing something really dumb and not seeing it but can anyone tell me why the following code would not be picking up changes in the passed in directory? When calling this code, creating and modifying files or directories in the passed in m_directory is ignored. But if I call PostQueuedCompletionStatus( m_hCompleti...

How to know a file is finished copying

I’m using ReadDirectoryChangesW to spy a folder, if I’m copying a large file to the folder, I can receive multiple FILE_ACTION_MODIFIED messages, it seems each time windows writes a large chunk of the file, you get the file modified notification for each time. I tried to use CreateFile API to check if the file can open by AP or not, but ...

Why does ReadDirectoryChangesW omit events?

Hi! I use ReadDirectoryChangesW to watch a specified directory and update indexing structures whenever a change is detected. I use the following code (roughly) var InfoPointer : PFileNotifyInformation; NextOffset : DWORD; ... while (not Terminated) do begin if ReadDirectoryChangesW (FDirHandle, FBuffer, FBufferLength, True, ...

Why use ReadDirectoryChangesW asynchronously?

I've read the documentation for ReadDirectoryChangesW() and also seen the CDirectoryChangeWatcher project, but neither say why one would want to call it asynchronously. I understand that the current thread will not block, but, at least for the CDirectoryChangeWatcher code that uses a completion port, when it calls GetQueuedCompletionSt...

ReadDirectoryChangesW thinks shortcut is being deleted right after creation

Hi, I am using this implementation of ReadDirectoryChangesW to monitor changes to the desktop. My program plans to run some small program when a file is created on the desktop. Now the problem I am running into is when I create a new shortcut via the right click context menu ReadDirectoryChangesW gets a notification saying the file ha...

Setting the last-modified-time of a directory opened for ReadDirectoryChangesW

I hava a Java program that needs to monitor a directory tree for changes. I have JNI code that uses ReadDirectoryChangesW(). The directory is opened like: HANDLE dirHandle = CreateFile( path, FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL ); and then I pass dirH...

File-level filesystem change notification in Mac OS X

I want my code to be notified when any file under (either directly or indirectly) a given directory is modified. By "modified", I mead I want my code to be notified whenever a file's contents are altered, it's renamed, or it's deleted; or if a new file is added. For my application, there can be thousands of files. I looked as FSEvents...

Can any linux API or tool watch for any change in any folder below e.g. /SharedRoot or do I have to setup e.g. inotify for each folder?

I have a folder with ~10 000 subfolders. Can any linux API or tool watch for any change in any folder below e.g. /SharedRoot or do I have to setup inotify for each folder? (i.e. I loose if I want to do this for 10k+ folders). I guess yes, since I've already seen examples of this inefficient method, for instance http://twistedmatrix.com/...

Win32 C++ ReadDirectoryChangesW "creation" and "modification" of file difference detect?

Here is the problem: I monitor a directory using Win32 API ReadDirectoryChangesW function. And I need to distinguish between newly created files and modified files. But there are problems... as always :( Cases: I monitor directory for new/modify (FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_SIZE). Problem: After file creation, ne...