|
|
|
|
|
- Special cases
- WLanguage procedure
fWatchDirectory (Function) In french: fSurveilleRepertoire
Warning
From version 2024, fTrackDirectory is kept for backward compatibility. This function has been replaced with fWatchDirectory.
Detects changes made to the contents of a directory. Only changes made to the files in the directory are detected. If a change is made, a specific procedure is executed in a thread.
sNomRepertoire is string = "C:\Temp\MonRep"
IF fWatchDirectory(sNomRepertoire, fSurveilleRépertoire_Callback, fwCreateFile + ...
fwModifyFile + fwDeleteFile + fwRename) THEN
Info("La mise sous surveillance du répertoire " + sNomRepertoire + " a réussi.")
ELSE
Info("La mise sous surveillance du répertoire " + sNomRepertoire + " a échoué.")
END
PROCEDURE fSurveilleRépertoire_Callback(sNomRepertoire, sNomFichier, nAction, sAncienNomFichier)
ExecuteMainThread(AjoutTable, sNomRepertoire, sNomFichier, nAction, sAncienNomFichier)
PROCEDURE AjoutTable(sNomRepertoire, sNomFichier, nAction, sAncienNomFichier)
sDesignationAction is string
SWITCH nAction
CASE fwCreateFile : sDesignationAction = "Création de fichier"
CASE fwDeleteFile : sDesignationAction = "Suppression de fichier"
CASE fwModifyFile : sDesignationAction = "Modification de fichier"
CASE fwRename : sDesignationAction = "Renommage de fichier"
END
TableAddLine(TABLE_MODIFICATIONS, sNomRepertoire, sNomFichier, ...
sDesignationAction, sAncienNomFichier)
Syntax
<Result> = fWatchDirectory(<Directory to watch> , <WLanguage procedure> [, <Changes to notify> [, <Subdirectory>]])
<Result>: Boolean - True if directory watch is enabled,
- False otherwise. To get more details on the error, use ErrorInfo.
<Directory to watch>: Character string Full name of the directory to be watched. <WLanguage procedure>: Procedure name Name of the WLanguage procedure ("callback") called when a change is made in the specified directory. <Changes to notify>: Optional Integer constant (or combination of constants) Changes made to the contents of the directory to be watched and for which the procedure is to be executed: | | fwAll | All actions are watched. Corresponds to fwCreateFile + fwModifyFile + fwRename + fwDeleteFile. Before version 29 Update 2, this constant was named ftAll. | fwCreateFile | Creation of a file or directory. Before version 29 Update 2, this constant was named ftCreateFile. | fwDeleteFile | Deletion of a file or directory. Before version 29 Update 2, this constant was named ftDeleteFile. | fwModifyFile | Changes to a file or directory. Before version 29 Update 2, this constant was named ftModifyFile. | fwRename | Renaming of a file or directory. Before version 29 Update 2, this constant was named ftRename. |
<Subdirectory>: Boolean - True (default) to process the sub-directories.
- False otherwise.
Remarks Special cases - fWatchDirectory only watches the contents of the directory. The changes of directory name or location are ignored.
- To stop watching the directory, use fWatchStop and fWatchStopAll.
- To watch the changes made to a file, use fWatchFile.
- Limitation: Only 5 directories can be monitored simultaneously.
WLanguage procedure The WLanguage procedure is run in a WLanguage thread. Please note: the following processes cannot be run in threads: - opening windows with WLanguage functions such as Open, Use, Close, ... If windows are to be handled in threads (a rare case), a specific management system must be set up. For more details, see Opening a window in a secondary thread.
- managing events.
- managing timers.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|