MiletusFileWatcher questions

I am trying to use MiletusFileWatcher in a Webcore App.
The following code is being used to set up FileWatcher:

GetMiletusPath( NP_DOCUMENTS, _filePAF );
fw := FileWatcher.Files.Add;
fw.FileName := _filePAF + '\Test.txt';
fw.OnChange := FileWatcherFiles0Change;' 

I am puzzled on how filewatcher is suppose to work.
Here are a couple of questions:

  1. if the file "Test.txt" does not exist the app is throwing an exception:
    "Invalid argument to date encode".
    Where and how in the code should the exception be handled.

  2. If the file does exist and the app is running, and then I edit "Test.txt" from an outside program. The onChange event is not firing.
    Why is the onChange event not firing?

Thanks in advance.

--Rick Howitt


  1. The TMiletusFileWatcher is for monitoring files that are already existing. However, the exception should not be raised so we applied an improvement. If a file does not exist it will still be "monitored". The OnChange event will trigger as soon as the file is created and after that whenever the file changes.
  2. An extra pair of backward slashes were added to the path and that prevented the event from triggering. We've applied a fix for this too.

Both changes will be available with the next update.

Sorry, I originally posted the comment below in the wrong thread.

I downloaded and installed TMS Web Core version 2.5.3.

The TMiletusStringList appears to be working correctly on a RaspberryPi.

However, I see no difference in the behavior of the TMiletusFileWatcher.
if the file exists and changes are made the oncChange event does not occur.
if the file that is being watched is removed an exception is reported "Invalid argument to date encoding".

Am I missing something.

below is the code I use to setup the FileWatcher.

--Rick Howitt

_fileWatch := MiletusFileWatcher2.Files.Add;
_fileWatch.FileName := APlaybackJSONclass.JSON_PAFN;
_fileWatch.onChange := MiletusFileWatcher1Files0Change;

_fileWatch := MiletusFileWatcher2.Files.Add;
_fileWatch.FileName := AScreenConfigJSONclass.JSON_PAFN;
_fileWatch.onChange := MiletusFileWatcher1Files1Change;


We were able to reproduce this and applied a fix for Raspberry Pi. The next version will contain the necessary changes.