Problem with finding files in a directory

JonHed
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);
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);
0
Answers
-
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.
Thomas0 -
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.0 -
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=267660 -
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.0
-
Thanks all for ideas.
Looks like it was the "cache" problem...0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions