LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Directory Listing

Does LabWindows/CVI 6 come with any funtions to get a listing of the files in a directory, like (opendir, readdir, closedir) on UNIX?
0 Kudos
Message 1 of 2
(3,391 Views)
You can call GetFirstFile(), then GetNextFile() in a loop to read all the files. The sndplay sample project (..\CVI\samples\sdk\audio\sndplay.prj) that ships with CVI has the following function.
/*---------------------------------------------------------------------------*/
/* Fill in the listbox with all of the sound files in the given directory. */
/*---------------------------------------------------------------------------*/
int FillListBoxWithWavsInDir(int panel, int listbox, char *directory)
{
char fileSpec[MAX_PATHNAME_LEN];
char fileName[MAX_FILENAME_LEN];
char fullPath[MAX_PATHNAME_LEN];
ClearListCtrl (panel, listbox);
MakePathname (directory, "*.wav", fileSpec);
if (GetFirstFile (fileSpec, 1, 0, 0, 0, 0, 0, fileName) == 0)

{
do
{
MakePathname (directory, fileName, fullPath);
InsertListItem (panel, listbox, -1, fileName, fullPath);
}
while (GetNextFile (fileName) == 0);
}
return 0;
}

For the CVI menu, goto Library >> Utility >> File Utilities (with flatten not selected).
Message 2 of 2
(3,391 Views)