解决方案 »

  1.   


    用 MFC 中的 CFileFind 类。
      

  2.   

     CFileFind finder; 
      CStringArray arrFileName;
     BOOL bWorking = finder.FindFile("C:\\*.*"); 
      while (bWorking) 
     { 
      bWorking = finder.FindNextFile(); 
       if(find.IsDot())   
              continue;   
      strFile = finder.GetFileName(); 
        arrFileName.Add(strFile);
     } 
      

  3.   

    参考:
    long handle; 
    struct _finddata_t filestruct;   
    char path_search[_MAX_PATH]; 
    handle = _findfirst("目录",&filestruct); 
    if((handle == -1)) return; 
    if( ::GetFileAttributes(filestruct.name)& FILE_ATTRIBUTE_DIRECTORY ) 

    if( filestruct.name[0] != '.' ) 

    _chdir(filestruct.name); 
    Search_Directory(szFilename); 
    _chdir(".."); 


    else

    if( !stricmp(filestruct.name, szFilename) ) 

    strcat(path_search,"\\"); 
    strcat(path_search,filestruct.name); 
    MessageBox(path_search);


    while(!(_findnext(handle,&filestruct))) 

      if( ::GetFileAttributes(filestruct.name) &FILE_ATTRIBUTE_DIRECTORY ) 

    if(*filestruct.name != '.') 

    _chdir(filestruct.name); 
    Search_Directory(szFilename); 
    _chdir(".."); 

    else 

    if(!stricmp(filestruct.name,szFilename)) 

    _getcwd(path_search,_MAX_PATH); 
    strcat(path_search,"\\"); 
    strcat(path_search,filestruct.name); 
    MessageBox(path_search); 



    _findclose(handle);