Link to home
Start Free TrialLog in
Avatar of masvmasv
masvmasv

asked on

FindFirstFile and FindNextFile Example...

Hi...
I need the FindFirstFile and FileNextFile example
Visual C++ Source code...

If you have, send to me.. thanks
Avatar of Shay050799
Shay050799

CString szFileToFind=szTempPath;
      szFileToFind += "\\log*.*";
      if(!find.FindFile(szFileToFind))
            return 0;
      find.FindNextFile();


Avatar of jkr
???

Simply use the following:

WIN32_FIND_DATA w32fd;
HANDLE hFind;

hFind = FindFirstFile ( "c:\\yourpath\\*.gif", &w32fd);

if ( INVALID_HANDLE_VALUE == hFind)
{
 // error
}
DoSomethingWithFile ( w32fd.cFileName);

while ( FindNextFile ( hFind, &w32fd))
{
  DoSomethingWithFile ( w32fd.cFileName);
}

if ( ERROR_NO_MORE_FILES != GetLastError()))
{
 // error
}
FindClose ( hFind);

Avatar of masvmasv

ASKER

Thanks...
But I need files in all hard disk, subdirectories too..

thanks
ASKER CERTIFIED SOLUTION
Avatar of wytze
wytze

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial