Results 1 to 3 of 3

Thread: files

  1. #1

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    files

    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"

    Code:
    	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);
    Matt

  2. #2
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    Your loop never ends... try
    Code:
    while(FindNextFile(fhwnd,&fd) !=0) {
    	MessageBox(NULL,fd.cFileName,"2",MB_OK);
    	SendMessage(dbox,LB_ADDSTRING,0, (LPARAM)fd.cFileName);
    
    }

  3. #3

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    Smile

    great, thank you
    Matt

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width