PDA

Click to See Complete Forum and Search --> : files


MPrestonf12
Aug 18th, 2002, 01:09 PM
this code keeps on returning the last file over and over and I can't figure out how to make it stop on "no more files"



int temp;
char wtxt[25];
HANDLE fhwnd;
BOOL fhwnd2;
WIN32_FIND_DATA fd;

temp = GetWindowText(dir, wtxt,25);
MessageBox(NULL,wtxt,"hello",MB_OK);
fhwnd = FindFirstFile(wtxt,&fd);

if(fhwnd == INVALID_HANDLE_VALUE){
return 0;
}else
//MessageBox(NULL,fd.cFileName,"1",MB_OK);
SendMessage(dbox,LB_ADDSTRING,0, (LPARAM)fd.cFileName);

while(fhwnd!=0) {
fhwnd2 = FindNextFile(fhwnd,&fd);
MessageBox(NULL,fd.cFileName,"2",MB_OK);
SendMessage(dbox,LB_ADDSTRING,0, (LPARAM)fd.cFileName);

}
FindClose(fhwnd);

jim mcnamara
Aug 18th, 2002, 04:04 PM
Your loop never ends... try

while(FindNextFile(fhwnd,&fd) !=0) {
MessageBox(NULL,fd.cFileName,"2",MB_OK);
SendMessage(dbox,LB_ADDSTRING,0, (LPARAM)fd.cFileName);

}

MPrestonf12
Aug 20th, 2002, 02:26 PM
great, thank you