LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get all the file names under certain folder

Hi
I'm using CVI and want to get the names of all files under certain folder. I do believe here somebody onced posted this kind of question, but I can not find it. Appreciate that somebody could help me on it.

Thanks!
Jacky
0 Kudos
Message 1 of 2
(4,447 Views)

You can use GetFirstFile ("path", 1, 0, 0, 0, 0, 0, file); and next iterate in a loop until GetNextFile (file); returns -1 (no more files). The online help for the first command explains how to delimit and perform this search.

As an example, this code finds all "temp.*" files in the application directory:

#include <utility.h>
static char path[MAX_PATHNAME_LEN];
static char file[MAX_PATHNAME_LEN];
static int r;

GetProjectDir (path);
MakePathname (path, "temp.*", path);
r = GetFirstFile (path, 1, 0, 0, 0, 0, 0, file);
if (!r) {
 do {
  r = GetNextFile (file);
 } while (!r);
}

Message Edited by Roberto Bozzolo on 12-14-2006 08:39 AM



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 2
(4,442 Views)