title: Recursive hard disk search with FindFirstFile & FindNextFile C++
body: <p>I am failing to see where i am going wrong. This current code skips straight to closefile. NOt processing any files, i may just be missing something obvious and it has been a long day. </p>
  
  <p>My function is meant to search the hard disk (c:) for a given file. EG example.txt. &amp;strFilePath here would be used in the FindFirstFile declaration. </p>
  
  <p>Any help would be appeciated. </p>
  
  <p>Thanks.</p>
  
  <pre><code>String Copy::SearchDrive( const String&amp; strFile, const String&amp; strFilePath, const bool&amp; bRecursive, const bool&amp; bStopWhenFound ) const
  {
      HANDLE hFile;
  
      WIN32_FIND_DATA file;
  
      hFile = FindFirstFile("C:\\", &amp;file);
  
      String strFoundFilePath = "";
  
      if ( hFile )
      {
          while ( FindNextFile( hFile, &amp;file))
          {
              String strTheNameOfTheFile = file.cFileName;
              // It could be a directory we are looking at
              // if so look into that dir
              if ( file.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY
                  &amp;&amp; bRecursive )
              {
                  String strNewFilePath = strFilePath + "\\";
                  strNewFilePath += strTheNameOfTheFile;
                  SearchDrive( strFile, strNewFilePath, bRecursive, bStopWhenFound );
              }
              else
              {
                  if ( strTheNameOfTheFile == strFile )
                  {
                      strFoundFilePath = strFilePath;
                      strFoundFilePath += "\\";
                      strFoundFilePath += strFile;
  
                      /// TODO
                      // ADD TO COLLECTION TYPE
  
                      if ( bStopWhenFound )
                      {
                          break;
                      }
                  }
              }
          }
          CloseHandle( hFile );
      }
      return strFoundFilePath;
  }
  </code></pre>