ReadDirectoryChangesW refresh problem

i was creating a small application which copies files from directory whenever the file size changes using ReadDirectoryChangesW.

but i am facing a weird problem. i need to go to the directory and refresh it manually (simple F5 refresh on that directory) to update the file size.

is there any way to do this programmatically ?
but i am facing a weird problem. i need to go to the directory and refresh it manually (simple F5 refresh on that directory) to update the file size.
What do you need to refresh? Do you mean the file system browser? That has nothing to do with your task. Just copy the file when you want to.

The file system can notify you when a change has occurred. But none of this has anything to do with the Windows Shell.
If you're using ReadDirectoryChanges() then you're doing the right thing.
What do you need to refresh? Do you mean the file system browser?

yes, thats the weird problem.
i know that ReadDirectoryChangesW() is doing it's job fine.

here is what happens..

1) my process is running in background.
2) it is not copying files or showing signs of FILE_NOTIFY_CHANGE_SIZE.
3) when i refresh(or sometimes just visit) the directory which is being monitored by ReadDirectoryChangesW()
from windows explorer my program detects changes in file system and copies the file.

that means the file size gets updated when i visit the directory(or refresh) from windows explorer.
Last edited on
The notification is asynchronous. I found that when the file system is busy, the notification can be considerably delayed.

Have you tried periodically running dir from a console to see if it triggers notification too? If it does, you can possibly do that in the background periodically to wake up the notification system.
by console do you mean command line? yes i tried to access it from command line, to trigger file size notification i need to perform some operation on that file like xcopy (which fails because of access restrictions but thats ok).
Last edited on
By background, I was thinking of a separate thread in your app that runs on a time, but a separate process will have the same effect.

It may or may not help, if it doesn't make the notification trigger faster, then forget it..
i will go with separate thread, thanks for helping.
Topic archived. No new replies allowed.