I am trying to figure out how to do this. For some reason, it ends at a certain point. I'm not very good at recursion, and I'm sure the problem is out there somewhere.
Also, even if I checked cFileName! = "..", it still appears at the end, not sure why, but "." no longer appears.
void find_files( wstring wrkdir )
{
wstring temp;
temp = wrkdir + L"\\" + L"*";
fHandle = FindFirstFile( temp.c_str(), &file_data );
if( fHandle == INVALID_HANDLE_VALUE )
{
return;
}
else
{
while( FindNextFile( fHandle, &file_data ) )
{
if( file_data.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY &&
wcscmp(file_data.cFileName, L".") != 0 &&
wcscmp(file_data.cFileName, L"..") != 0 )
{
find_files( wrkdir + L"\\" + file_data.cFileName );
}
else if( file_data.dwFileAttributes != FILE_ATTRIBUTE_HIDDEN &&
file_data.dwFileAttributes != FILE_ATTRIBUTE_SYSTEM )
{
results << wrkdir << "\\" << file_data.cFileName << endl;
}
}
}
}
After changing the program, the program does not list the remaining files.
For example, if there is a subfolder named test, it lists everything inside the test, but does not complete the listing of files inside the specified source directory.
source
share