The SEARCH function is 30 to 70% faster than FILE-INFO:FILE-NAME to test for file existence if you expect that the file searched exists most of the time (if the file does not exist, both methods are equivalent). (works for file only, not directory)
You can have some fun confirming this with the following code (It doesn't take many loops to have execution times in seconds!):
&SCOPED-DEFINE NumLoops 500 DEFINE VARIABLE cFileToFindList AS CHARACTER NO-UNDO INITIAL "pm\KBC\GetSpecialKitNo.p|c:\req.txt". /* pipe '|' delimited list */ DEFINE VARIABLE cFileToFind AS CHARACTER NO-UNDO. DEFINE VARIABLE iNumFileToFinds AS INTEGER NO-UNDO. DEFINE VARIABLE iFileToFindIndex AS INTEGER NO-UNDO. DEFINE VARIABLE i AS INTEGER NO-UNDO. DEFINE VARIABLE lFileExists AS LOGICAL NO-UNDO. DEFINE VARIABLE iEmptyLoopTime AS INTEGER NO-UNDO. DEFINE VARIABLE iMethodTime AS INTEGER NO-UNDO. DEFINE VARIABLE cResults AS CHARACTER NO-UNDO INITIAL "--Results--~n". ETIME(TRUE). DO i = 1 TO {&NumLoops}: END. iEmptyLoopTime = ETIME. iNumFileToFinds = NUM-ENTRIES(cFileToFindList, "|"). DO iFileToFindIndex = 1 TO iNumFileToFinds: ASSIGN cFileToFind = ENTRY(iFileToFindIndex, cFileToFindList, "|") cResults = cResults + "~n~nFile:" + cFileToFind . ETIME(TRUE). DO i = 1 TO {&NumLoops}: /* Method 1 */ ASSIGN FILE-INFORMATION:FILE-NAME = cFileToFind lFileExists = FILE-INFORMATION:FULL-PATHNAME <> ? . END. iMethodTime = ETIME. cResults = cResults + "~nMethod 1:" + STRING(iMethodTime - iEmptyLoopTime). ETIME(TRUE). DO i = 1 TO {&NumLoops}: /* Method 2 */ lFileExists = SEARCH(cFileToFind) <> ?. END. iMethodTime = ETIME. cResults = cResults + "~nMethod 2:" + STRING(iMethodTime - iEmptyLoopTime). END. /* DO iFileToFindIndex = 1 TO iNumFileToFinds */ MESSAGE cResults VIEW-AS ALERT-BOX.
A couple of results on my machine:
File:C:\path1\File1.w
Method 1:110
Method 2:31
File:relative\File2.w
Method 1:6968
Method 2:3969
File:Relative2\File3.p
Method 1:5922
Method 2:4250
File:c:\File4.txt
Method 1:93
Method 2:47