Reload externally modified files automatically?

Started by
2 comments, last by RidiculousX 15 years ago
Basically, if I have a tool A that creates a file, and then another tool B that loads that file, and then tool A modifies that file, how can tool B be notified of this situation so it can respond to it under Windows? I'm not having good luck searching the net, I don't think I'm wording the problem correctly.
Advertisement
Assuming both tools are yours, you won't be able to do this with two arbitrary programs, you can take a look at the following resources:
How to get the File/Directory change notifications? (C++/MFC)
Watching a File in C#

If those two aren't enough, then you just want to Google "File change notifications" along with whatever language or platform you are using for the specifics. Happy searching!
Most applications that have this feature simply check the "Last Modified" timestamp of all the files they have open when they receive focus. In the vast majority of cases, that's "good" enough (because most of the time, you have to switch to Application B to modify the file, then when you switch back to Application A, it can detect when it gets the "received focus" message).

If you look at Visual Studio, for example, that's all it does - it only detects that the file has be modified when you give it focus.

Not sure if that'll work for you...
I see. Thanks! That helps a lot.

This topic is closed to new replies.

Advertisement