Board index » cppbuilder » How get all files of a directory including their subfolders...?

How get all files of a directory including their subfolders...?


2005-08-27 06:41:59 PM
cppbuilder38
dear builders,
i'm using a drag 'n drop funcxtion to get all files of a directory..but the
function
only gets the files of the topfolder, NOT the files of the subfolders...
can someone tell me what to modify in my function....?
Oren
/*******************************************************/
if(FileGetAttr(FileName) & faDirectory)
{
TSearchRec searchRecord;
AnsiString strFolder = FileName;
int result = FindFirst(strFolder + "\\*.*", faAnyFile &
~faDirectory, searchRecord);
while(result == 0)
{
String dir_File = AnsiString(FileName) + "\\" +
searchRecord.Name;
IsAscii(dir_File);
FileBox->Items->Add(dir_File);
FileShow(dir_File);
result = FindNext(searchRecord);
}
FindClose(searchRecord);
}
/*******************************************************/
 
 

Re:How get all files of a directory including their subfolders...?

"Oren Halvani" < XXXX@XXXXX.COM >wrote in message
Quote
i'm using a drag 'n drop funcxtion to get all files of a directory..
but the function only gets the files of the topfolder, NOT the files
of the subfolders...
That is because your code is completely ignoring the subfolders altogether.
You did not search the newsgroup archives at www.deja.com yet, did
you? Sample code has been posted MANY MANY times before showing how to
perform recursive searches of subfolders, including filename filtering if
desired.
Gambit