Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 2 Jahren, 10 Monaten
Letzter Beitrag:
vor 2 Jahren, 10 Monaten
Beteiligte Autoren:
Fabrice Harari, David van Pelt

fTrackDirectory - 5 files

Startbeitrag von David van Pelt am 07.04.2015 12:16


I'm tracking a folder with fTrackDirectory with 2 sub dirs.
As expected when I add a file in one of the folders a procedure will run.
The odd thing is, when I add 5 files or more my service stops working.
I don't get any errors and the procedure is only run once.

The remarks on this function tells that only 5 directories can be tracked.
But I'm talking about files, not dirs so is the documentation wrong or am I doing something wrong?


PROCEDURE handleNewFile(LOCAL sFileDir is string, LOCAL sFileName is string, nAction is int, sFormerFileName is string)
nNewSubscript is int = ArrayCount(garrFileList)+1

// Manual rename for retry, should be noticed
IF nAction = ftRename THEN
IF sFormerFileName = sFileName THEN
ServiceWriteEventLog("Retry handle file, name change with no change.",elInformation)
ServiceWriteEventLog("Retry handle file, name changed old name: "+sFormerFileName+" new name: "+sFileName,elInformation)

// Finding the type and create the right class
SWITCH Lower(ExtractString(sFileName,1,"\",FromBeginning))
CASE "ags"
ArrayAdd(garrFileList, new AgsMessage(sFileDir+["\"]+sFileName, nNewSubscript))
CASE "sagitta"
ArrayAdd(garrFileList, new SagittaMessage(sFileDir+["\"]+sFileName, nNewSubscript))
CASE "emcs"
ArrayAdd(garrFileList, new EmcsMessage(sFileDir+["\"]+sFileName, nNewSubscript))
ServiceWriteEventLog("Unknown file, can't parse... Moving file to safe location..."+RC+Lower(ExtractString(sFileDir,1,"\",FromEnd)) + " - " + sFileName, elWarning)
fMoveFile(sFileDir+["\"]+sFileName, gsSaveLocation+["\"]+sFileName)

Please don't mind the arraycount stuff, I know it's `wrong` but it isn't the problem for sure.

Thanks in advance,


Hi David

Maybe yo have a speed problem... If you create 5 files very rapidly, your process is going to be called 5 times as fast as the files are created...

If you did not code your process to accept that, then you may just be crashing because of it...

So, what I would do in a case like this one is:
- in the procedure called by ftrack... I would ADD the file information in an array
- in a process called in a loop/timer, I would process the content of the array

To test if my hypothesis is correct, comment out ALL the code in the procedure called when a file is tracked ans just trace its information in a file... if you have all of them, then you may want to reorganize things

Best regards

von Fabrice Harari - am 07.04.2015 13:02
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.