Here's a complete prog. Will find jpg files in the drive you want, I've used the Win32 API FindFirstFile/FindNextFile, you can convert to C's findfirst/findnext easy if you want to..<br>
<br>
#include "windows.h"<br>
#include "stdio.h"<br>
<br>
void search_folder( const char *pszFolderName, const char *pszExt )<br>
{<br>
// add \*.* to folder name to search for all files and folders<br>
char szBuffer[ _MAX_PATH ];<br>
wsprintf( szBuffer, "%s\\*.*", pszFolderName );<br>
<br>
// find first file<br>
WIN32_FIND_DATA wfd;<br>
HANDLE h = FindFirstFile( szBuffer, &wfd );<br>
if( h != INVALID_HANDLE_VALUE )<br>
{<br>
do<br>
{<br>
// check if its a folder<br>
if( wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )<br>
{<br>
// skip . and .. or else we'd recurse to hell<br>
if( lstrcmpi( wfd.cFileName, "." ) && lstrcmpi( wfd.cFileName, ".." ) )<br>
{<br>
// build new folder name and search it<br>
wsprintf( szBuffer, "%s\\%s", pszFolderName, wfd.cFileName );<br>
search_folder( szBuffer, pszExt );<br>
}<br>
}<br>
else<br>
{<br>
// its a file, check extension<br>
char szTempExt[ _MAX_PATH ];<br>
_splitpath( wfd.cFileName, NULL, NULL, NULL, szTempExt );<br>
if( lstrcmpi( (char*) ( szTempExt + 1 ), pszExt ) == 0 )<br>
{<br>
// got one, build full file name and show it<br>
wsprintf( szBuffer, "%s\\%s", pszFolderName, wfd.cFileName );<br>
printf( "%s\n", szBuffer );<br>
}<br>
}<br>
}<br>
while( FindNextFile( h, &wfd ) ); // find next file<br>
<br>
CloseHandle( h );<br>
}<br>
}<br>
<br>
<br>
main()<br>
{<br>
search_folder( "c:", "jpg" );<br>
<br>
return 0;<br>
}<br>
<br>
<br>
: Anyone could provide me an algorithm to do that?<br>
: Something that covers all the folders starting from the root?<br>
: Thanx.<br>
: <br>
<br>