This method allows you to monitor the contents of one or more directories on the system and be notified of any changes occurring within them. Its API is quite simple and takes up to three arguments:
When a change occurs the FILESYSTEM object raises a CHANGED event to notify you of the fact. As with any other OI window or control you can write your own FILESYSTEM CHANGED event handler to respond to this - note that this is per application, not per window.
Like the standard CHANGED event the relevant change information is passed in the "New Data" argument - in this case "NewData" contains a dynamic array with two fields:
<1> The name and path of the file being changed <2> A code specifying the type of change
Technical note: The WATCHDIR method is based on the underlying ReadDirectoryChangesW Windows API function, details of which can be found HERE.
FILESYSTEM object
$insert ms_Win_FileNotify_Equates // Only watch for files being created in the specified dir ... watchFlags = FILE_NOTIFY_CHANGE_CREATION$ bIncludeSubDirs = FALSE$ call exec_Method( "FILESYSTEM", "WATCHDIR", "c:\temp\incoming", bIncludeSubDirs, watchFlags ) Example FILESYSTEM CHANGED event: $insert ms_Win_FileNotify_Equates changeFile = newData<1> changeCode = newData<2> info = "" begin case case ( changeCode = FILE_ACTION_ADDED$ ) info = "Added" case ( changeCode = FILE_ACTION_REMOVED$ ) info = "Deleted" case ( changeCode = FILE_ACTION_MODIFIED$ ) info = "Modified" case ( changeCode = FILE_ACTION_RENAMED_OLD_NAME$ ) info = "Renamed From" case ( changeCode = FILE_ACTION_RENAMED_NEW_NAME$ ) info = "Renamed To" end case call send_Info( info : " ": changeFile )