|
-
Mar 28th, 2001, 05:10 PM
#1
Thread Starter
Hyperactive Member
I've been trying to make this function search subfolders but I can't get it to work. Heres the code.
Code:
int findfiles(char *p)
{
WIN32_FIND_DATA Find;
HANDLE hfind;
BOOL hfind2;
hfind = FindFirstFile(p, &Find);
if(hfind == INVALID_HANDLE_VALUE){
MessageBox(NULL, "Error opening file", "FindFiles", MB_OK|MB_ICONERROR);
}else
SendMessage(NULL, LB_ADDSTRING, 0, (LPARAM) Find.cFileName);
while(hfind2!=0){
hfind2 = FindNextFile(hfind, &Find);
if(GetFileAttributes(Find.cFileName)==FILE_ATTRIBUTE_DIRECTORY){
findfiles(Find.cFileName);
}
SendMessage(listbx,LB_ADDSTRING,0,(LPARAM) Find.cFileName);
}
FindClose(hfind);
return 0;
}
Thanks
Matt 
-
Mar 29th, 2001, 03:57 AM
#2
Fanatic Member
i dont think i follow ya, where is listbx coming from in:
SendMessage(listbx,LB_ADDSTRING,0,(LPARAM) Find.cFileName);
??-- also, your recursion code is in a while loop...
i dont know windows programming, but the problem might be that it doesnt even find the sub-folders.. did you try debugging it? see if it at least "finds" the sub-folders, then if it does, i have no clue... but it looks like it should work
-
Apr 5th, 2001, 10:54 AM
#3
Lively Member
When you hit a sub-directory, you may want to add a "\*.* "mask to the path you pass to yourself. Moreover, you'll likely get into a recursion loop if you don't filter out entries "." and "..".
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
|