Для винды...
| Код | #include <iostream> #include <windows.h> #include <conio.h>
using namespace std;
void ShowFiles( wstring dir ) { wcout << dir.c_str() << endl; ::SetCurrentDirectory( dir.c_str() );
WIN32_FIND_DATA tFind;
HANDLE hFind = ::FindFirstFile( L"*.*", &tFind );
if( hFind == INVALID_HANDLE_VALUE ) return;
do { if( tFind.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { if( wcscmp( tFind.cFileName, L"." ) != 0 && wcscmp( tFind.cFileName, L".." ) != 0 ) { wstring nextDir = dir; nextDir += tFind.cFileName; nextDir += L"\\"; ShowFiles( nextDir ); } } else { wstring file = dir; file += tFind.cFileName; wcout << file.c_str() << endl; } if( !::FindNextFile( hFind, &tFind ) ) { ::FindClose( hFind ); hFind = INVALID_HANDLE_VALUE; } } while( hFind != INVALID_HANDLE_VALUE );
}
int main( int argc, char* argv[] ) { setlocale(LC_ALL, "Russian"); ShowFiles( L"С:\\" ); getch(); return 0; }
|
|