This example program demonstrates how to recursively find all the files and directories in a directory by calling GetFirstFile and GetNextFileWhen you start the program, the main function calls a function to populate the list with the names of all the files and directories under the current project directory. All the directory names have (Directory) next to the names. For example, a directory called myDir appears as myDir (Directory) in the list.
Because there is only one copy to store the file information returned by GetNextFileby calling GetNextFile recursively, that copy gets overwritten. Therefore, you need to store all the file names returned by successive calls to GetNextFile in a string array (for example, char[ ][ ]) first. Then, you can use another loop to iterate the string array and do whatever you want to do with the files, such as displaying the file names in a list.
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.