How would I hook into a file that's currently in use by another program, which constantly writes out to it? Let's say, there's a text file with 10 lines. When I start my app it has to detect and read any content from there on everytime the writing program saves its content. Can this be done without a constant check on the filesize/date?
Asked
Active
Viewed 1,288 times
2 Answers
3
You could monitor the folder for changes using the ReadDirectoryChangesW API.
Keep track of the last position you read to, and when you receive a change notification for that file, read from there to the end of the file (as it currently stands).
An example of how to use the ReadDirectoryChangesW API is here:
2
Kinda similar to this: Monitor files similar to System Internal's/Microsoft's FileMon/Process Monitor

Community
- 1
- 1

Chris Thornton
- 15,620
- 5
- 37
- 62