Click to See Complete Forum and Search --> : Get all file from a directory
Kacem
March 29th, 1999, 03:09 AM
Hi
Is it possible to Get a list of files from one directory ?
Like this function "DlgDirList()", But we wnat to Get a list of file in other control (our control), not in ListBox
"DlgDirList ( D->m_hWnd, path, IDC_LIST, 0, DDL_READWRITE ) ;"
Thanks
Franky Braem
March 29th, 1999, 03:14 AM
You can try the functions _findfirst, _findnext
Kacem
March 29th, 1999, 03:18 AM
What I try to do now; (findfirst)
How to specify for this function a directory for search ?
Franky Braem
March 29th, 1999, 03:31 AM
You can check the attrib field of the _finddata_t structure for the value _A_SUBDIR .
See for more info in MSDN : _find, _wfind functions.
Kacem
March 29th, 1999, 03:42 AM
There aren't _A_SUBDIR value in this struct
struct _finddata_t {
unsigned attrib;
time_t time_create; /* -1 for FAT file systems */
time_t time_access; /* -1 for FAT file systems */
time_t time_write;
_fsize_t size;
char name[260];
};
Thanks
Franky Braem
March 29th, 1999, 04:10 AM
You have to use the attrib-member.
Example which displays all subdirs of the current directory
struct _finddata_t c_file;
long hFile;
if ( (hFile = _findfirst("*.*", &c_file)) == -1L )
{
printf("No files found!\n");
}
else
{
if ( c_file.attrib & _A_SUBDIR )
printf("Subdir found : %s\n", c_file.name);
while ( _findnext(hFile, &c_file) == 0 )
{
if ( c_file.attrib & _A_SUBDIR )
printf("Subdir found : %s\n", c_file.name);
}
_findclose(hFile);
}
Hope this helps.
Kacem
March 29th, 1999, 04:20 AM
Sory, Is not I I want to do
I mean I want to a same search (findfirst) in different directory
Like c:\windows and C:\toto. I have to change a Directory for that OR specify a directory in findfirst function
How can I do that ?
Thanks
Franky Braem
March 29th, 1999, 04:34 AM
You can specify another directory in the _findfirst function.
example :
struct _finddata_t c_file;
long hFile = _findfirst("c:\\winnt\\*.dll", &c_file);
...
_findclose(hFile);
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.