I have a routine in a report program that reads the file names in a Windows directory using the Navision virtual FILE. It moves processed files to another directory.
The problem I have is that when I rerun the report which runs the routine again, it reads the file names from the directory that existed at the time of the first read, even though they are no longer there.
The only fix I have found is to exit Navision and get back in - which is not practical for turning over to a non-technaical user.
Is there any way of forcing Navision to read the current contents of a Windows directory?
0
Comments
My Blog - nav.education
A workaround ay be to read another directory and see if that clears the cache on the directory I want.
http://mibuso.com/blogs/davidmachanick/
We use this for dataports once the import is completed. Make sure it's closed - Use File.Copy & then Finally Erase The Orig.
CurrFile.CLOSE;
SavedFileName := FORMAT(WORKDATE,0,'<Year4>'+'-'+'<Month Text,3>'+'-'+'<Day,2>')+'.txt';
FILE.COPY(CurrReport.FILENAME,FilePath+SavedFileName);
ERASE(CurrReport.FILENAME);
http://www.BiloBeauty.com
http://www.autismspeaks.org
The report exits when complete.
Then if we run the report again reading the same directory, it "reads" the old file names that were deleted, and does not read any new files that were added.
It acts like it read the contents of the directory into cache and reads the cached directory. Since the report object was closed and the rerun, it seems lke it is a NAV client issue.
http://mibuso.com/blogs/davidmachanick/
There are 2 solutions:
1) Quick and Dirty (but very easy to implement)
Before reading the correct folder place the filter onto another existing folder, do a findfirst and only after that process your folder. NAV only has one cache for the table File. So the cache is always cleared every time you read another folder.
2) The correct one (much more work to implement):
Move the code that reads the table File and all subsequent code into a codeunit. In your report create a local variable for that codeunit and run it. This also solves it as local vaiables are always destroyed (and the file list cache cleared) when the report finishes.
Best regards, Frank
FD Consulting
(as FDickschat wrote in his post)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
the problem with searching the forum is that you have to put in the words that exactly match those used before.
google is usually better, but in this case did not come up with the answer
http://mibuso.com/blogs/davidmachanick/