Home > Blockchain >  How to loop through nested directories in Foxpro given the initial start directory
How to loop through nested directories in Foxpro given the initial start directory

Time:01-01

I am trying to loop through a local directory and print out the name of all subdirectories and files within. The start path of the search is provided, and it can be possible that there are nested directories.

The start directory looks like:

enter image description here

and for example, within the appendix directory, we have:

enter image description here

And the directory nesting could go on as many times, but for this example these two sub directories a1 and a2 only contain some .txt files.

I have seen some other similar question like Result image

Edited: As for the OP's comment:

lcFileOrFolder values are . or .. Why does adir() create values like this?

The dots get into the first ADir() result elements when its 3rd parameter is "D"(irectory). IDE Command Window example:

CD HOME()
? ADIR(laDir, "*")
? laDir[1,1] && no "D" no dots, first element is a file name, e.g."Beautify.APP"
? ADIR(laDir, "*", "D")
? laDir[1,1] && dot "."
? laDir[2,1] && double dot ".."

That behavior is not documented AFAIK, might perhaps have been an ancient feature related to the DOS/FoxPro CD command

  • Related