Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   Showing files in a subdirectory (http://www.go4expert.com/forums/files-subdirectory-t8722/)

stp 9Feb2008 01:05

Showing files in a subdirectory
 
This code show the files in a directory. But how to show and the files in the subdirectories

Code:


#include <iostream>
#include <windows.h>
using namespace std;


int main()
{
WIN32_FIND_DATA fd;
HANDLE hFind;


hFind = FindFirstFile("C:\\C++\\*", &fd);


cout<<fd.cFileName<<"\n";

    while(FindNextFile(hFind, &fd) != 0)
    {
    cout<<fd.cFileName<<"\n";
    }

FindClose(hFind);

return 0;
}


shabbir 9Feb2008 10:43

Re: Showing files in a subdirectory
 
You move your code into main to some other function and loop through it recursively to populate for all the directories and sub-directories.


All times are GMT +5.5. The time now is 12:04.