Here's mine from some time back (the set step on is so you can easily view the array's contents in debug), I have it posted as a FAQ at
http://www.tek-tips.com/faqs.cfm?fid=4256Dimension aryFiles(1)
=GetAllFiles(GETDIR(), @aryFiles)
SET STEP ON
FUNCTION GetAllFiles(cDirectory, aryParam)
LOCAL ARRAY aryTemp(1,5)
LOCAL nCount, nMax, nLen, cFile
SET DEFAULT TO (cDirectory)
=ADIR(aryTemp, "*.*","AHRSD",1)
nMax = ALEN(aryTemp,1)
FOR nCount = 1 TO nMax
cFile = ALLTRIM(aryTemp(nCount,1))
IF !(cFile == ".") AND !(cFile == "..")
IF "D" $ aryTemp(nCount,5)
=GetAllFiles(ADDBS(cDirectory + cFile), @aryParam)
ELSE
nLen = ALEN(aryParam)
IF !EMPTY(aryParam(nLen))
DIMENSION aryParam(nLen + 1)
nLen = nLen + 1
ENDIF
aryParam(nLen) = cDirectory + cFile
ENDIF
ENDIF
ENDFOR
ENDFUNC
>I heavily modified some code I found from a Michael Reynolds. It works like Adir() but has full file paths for every file and every subdirectory and subdirectory file below the passed path.
>
>
>
>*!*this fills the passed array (1,5) with full file paths for all files and directories *!*below the
>*!*passed path as well as file attributes, array must be passed by name, the last row *!*in the
>*!*array is blank
>
>Function Recurse
>LPARAMETERS pcDir, lcPaths
>Local lnPtr, lnFileCount, laFileList, lcDir, lcFile
>
>IF RIGHT(pcDir,1) != "\"
> pcDir = pcDir + "\"
>ENDIF
>
>IF DIRECTORY(pcDir) = .F.
> RETURN 1
>ENDIF
>
>Dimension laFileList(1)
>
>*Read the chosen directory.
>lnFileCount = Adir(laFileList, pcDir + '*.*', 'D')
>For lnPtr = 1 To lnFileCount
>
> If 'D' $ laFileList(lnPtr, 5)
> *Get directory name.
> lcDir = laFileList(lnPtr, 1)
>
> *Ignore current and parent directory pointers.
> If lcDir != '.' And lcDir != '..'
> &lcPaths(Alen(&lcPaths,1), 1) = pcDir + lcDir
> *Expand the array one row
> Dimension &lcPaths(Alen(&lcPaths,1) + 1, 5)
> *Call this routine again.
> Recurse(pcDir + lcDir, lcPaths)
> Endif
> Else
> *Get the file properties.
> &lcPaths(Alen(&lcPaths,1), 1) = pcDir + laFileList(lnPtr,1)
> &lcPaths(Alen(&lcPaths,1), 2) = pcDir + ALLTRIM(STR(laFileList(lnPtr,2)))
> &lcPaths(Alen(&lcPaths,1), 3) = pcDir + DTOC(laFileList(lnPtr,3))
> &lcPaths(Alen(&lcPaths,1), 4) = pcDir + laFileList(lnPtr,4)
> &lcPaths(Alen(&lcPaths,1), 5) = pcDir + laFileList(lnPtr,5)
> *Expand the array one row
> Dimension &lcPaths(Alen(&lcPaths,1) + 1, 5)
> Endif
>
>ENDFOR
> RETURN 0
>Endfunc