Find File in folder - problem when using it twice

nnohrnnohr Member Posts: 18
Hi,

I want to find files from a specific directory from Navision. I have placed some code in table 38 (Purchase Header), which is called from Form 50 (Purchase Order).

Following code is in table 38, where folfile is FILE variable:

CLEAR(folfile);
folfile.SETRANGE(folfile.Path,PurchaseSetup."Documentscanning Path");
folfile.SETFILTER(folfile.Name,'%1','*.pdf');
IF folfile.FINDFIRST THEN BEGIN
NewFilePath := 'xxxxxxxxxxx';

FILE.RENAME(folfile.Path+folfile.Name,NewFilePath);
END;

I have following problems:

1. I open Form 50 and then place a PDF file in the directory, then I call the code above. No file has been found.
2. I call the code above, and the file has been renamed to another location. Without closing Form 50, I call the code again and Navision tells me that it finds a file, even if there is no and when RENAME, Navision fails. I call a CLEAR before, so I do not understand why Navision tells me that there is a file when the file has already been moved to another location.

Hope someone can help me.

Thank you in advance.

Comments

Sign In or Register to comment.