Problem with finding files in a directory

JonHedJonHed Member Posts: 4
Using the system table "File" to find files in a directory.
The code is run by NAS and the codeunit is set to SingleInstance=Yes

Version of Navision: 4 SP3

The problem is that after a while new files are not found, but after restarting NAS the files are found.

Any ideas anyone?


The code:

ImportFiles.RESET;
SELECTLATESTVERSION;
ImportFiles.SETFILTER(Path, Setup."Path Importfiles");
ImportFiles.SETRANGE("Is a file",TRUE);
ImportFiles.SETFILTER(Name, '%1', Setup."Filename Mask");
IF ImportFiles.FIND('-') THEN
REPEAT
[ code to handle the files ]

UNTIL (ImportFiles.NEXT = 0);

Answers

  • ta5ta5 Member Posts: 1,164
    Do you move/delete the files in the section "[ code to handle the files ]"?
    If yes then the loop may break too early. I had similar problems and solved it using a buffer table containing the file names to operate the loop on.

    Hope this helps.
    Thomas
  • JonHedJonHed Member Posts: 4
    I do move the files.
    I've checked the funktion and it does capture all the files at the moment and processed them.

    The issue is that later in time new files will not be found. This routine runs once every minute.

    Files ar found as they occur, and it works like for a couple of hours and then the problem shows.
  • ta5ta5 Member Posts: 1,164
    Could be a refresh problem, depending on how you call the function with the loop and whether the table is local or global.

    Try this:
    viewtopic.php?f=23&t=26766
  • DenSterDenSter Member Posts: 8,304
    Using the File virtual table is not very user friendly. Doing a FIND does not re-read the folder, which is really annoying. You will have to set the filter to something else, do a FIND, then set the filter back and do another FIND to refresh the file list.
  • JonHedJonHed Member Posts: 4
    Thanks all for ideas.
    Looks like it was the "cache" problem...
Sign In or Register to comment.