|
-
March 29th, 1999, 04:09 AM
#1
Get all file from a directory
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
-
March 29th, 1999, 04:14 AM
#2
Re: Get all file from a directory
You can try the functions _findfirst, _findnext
-
March 29th, 1999, 04:18 AM
#3
Re: Get all file from a directory
What I try to do now; (findfirst)
How to specify for this function a directory for search ?
-
March 29th, 1999, 04:31 AM
#4
Re: Get all file from a directory
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.
-
March 29th, 1999, 04:42 AM
#5
Re: Get all file from a directory
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
-
March 29th, 1999, 05:10 AM
#6
Re: Get all file from a directory
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.
-
March 29th, 1999, 05:20 AM
#7
Re: Get all file from a directory
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
-
March 29th, 1999, 05:34 AM
#8
Re: Get all file from a directory
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);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|