Questions tagged [readdirectorychangesw]

This WinAPI function retrieves information that describes the changes within the specified directory

https://learn.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-readdirectorychangesw

66 questions
31
votes
4 answers

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 mean 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…
Paul J. Lucas
  • 6,895
  • 6
  • 44
  • 88
21
votes
3 answers

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.…
SpecialK
13
votes
2 answers

Why does ReadDirectoryChangesW omit events?

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)…
jpfollenius
  • 16,456
  • 10
  • 90
  • 156
13
votes
1 answer

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).…
user26404
  • 1,371
  • 4
  • 27
  • 38
10
votes
2 answers

Asynchronous ReadDirectoryChangesW - GetQueuedCompletionStatus always times out

Exactly as it sounds, I'm attempting asynchronous ReadDirectoryChangesW with IO Completion and it isn't working, specifically, GetLastError repeatedly returns 258 (GetQueuedCompletionStatus timeout). I have structs: typedef struct dirinfo_struct { …
user257111
9
votes
1 answer

How to deal with Windows' ReadDirectoryChangesW() and its mixed long/short filename output?

I am developing a piece of C code that uses ReadDirectoryChangesW() to monitor changes under a directory in Windows. I have read the related MSDN entries for ReadDirectoryChangesW() and the FILE_NOTIFY_INFORMATION structure, as well as several other…
thkala
  • 84,049
  • 23
  • 157
  • 201
8
votes
1 answer

Delphi wait until a file copy process is complete

I have a thread that uses ReadDirectoryChangesW to notify me when a file is added or deleted in a folder. For each new image, I open the file and create a thumbnail of the image. It would seem however that I receive the notification before the file…
Pieter van Wyk
  • 2,316
  • 9
  • 48
  • 65
7
votes
1 answer

What's the difference between ReadDirectoryChangesW() and FindFirstChangeNotification() APIs?

I want to know any change files of the specific directory. So, I figured out ReadDirectoryChangesW() and FindFirstChangeNotification() - FindNextChangeNotification() APIs. Then, I implemented using ReadDirectoryChangesW() function. But, I don't know…
strawnut
  • 359
  • 5
  • 21
6
votes
3 answers

When calling ReadDirectoryChangesW, only the first call returns any changes (both sync and async)

The following is a minimal program which uses ReadDirectoryChangesW. The problem I am having is that only the first call to GetQueuedCompletionStatus returns. The second time through the loop it blocks forever no matter how many changes are made to…
Michael Spencer
  • 1,029
  • 9
  • 18
5
votes
1 answer

Asynchronous ReadDirectoryChangesW call blocks the thread from exiting

Introduction: I am writing a small app that monitors a certain directory for newly added files. I would like to put the monitoring code in a separate thread, so I can leave the main thread free for other stuff and cancel the monitoring thread when I…
5
votes
3 answers

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…
Paul J. Lucas
  • 6,895
  • 6
  • 44
  • 88
5
votes
1 answer

Why ReadDirectoryChangesW, with only FILE_NOTIFY_CHANGE_LAST_WRITE filter, does signal more than one event on file editing?

I am monitoring in separate thread application configuration file, which in some cases may be INI in another XML or another. Code of thread monitoring directory (in Delphi) is something like this: procedure TWatcherThread.Execute; type …
ALZ
  • 1,997
  • 2
  • 27
  • 44
4
votes
3 answers

ReadDirectoryChangesW blocks deleting the watched directory

I am trying to watch a directory for create/delete/rename changes on windows with python using the ReadDirectoryChangesW API. This is my code and it is working fine: results = win32file.ReadDirectoryChangesW(self.hDir, 8192, True, self.type, None, …
Mohamad
  • 61
  • 1
  • 2
  • 5
4
votes
2 answers

ReadDirectoryChangesW unable to detect and handle deletion of watched directory

I try to monitor the contents of a directory tree, which my contain a huge ammount of files (many directories with 9000 files per directory as an example). Synchron mode: I first tryied using ReadDirectoryChangesW in blocking mode (synchronous),…
4
votes
1 answer

ReadDirectoryChangesW seems to be missing events

I've been trying to get ReadDirectoryChangesW to monitor a subtree for file changes, but I have found that I am getting inconsistent results. The following is a self contained test case which illustrates the problem. When I run this it sometimes…
Eric Vasilik
  • 362
  • 2
  • 14
1
2 3 4 5