Page 1 of 1

Read the last changes in a log file

PostPosted: July 22nd, 2010, 9:41 am
by Zvikai
Hi all,

Is there a way to monitor a text file (log file) for changes and then read the last block of text that was appended ?

Thanks,
Z

Re: Read the last changes in a log file

PostPosted: July 30th, 2010, 2:09 am
by Kambiz
I don't know how to monitor a single file, but I know Windows has API for monitoring changes in a directory.

  • FindFirstChangeNotification
  • FindNextChangeNotification
  • FindCloseChangeNotification
The TShellChangeNotifier component implements these APIs, and is very easy to use.

The TShellChangeNotifier component is part of the Shell Controls package, which is shipped with Delphi but is not installed by default. When you install the Shell Controls package, the components will appear in the Samples palette.