C++ / C Program to show files and Folders recursively

C++ / C program to show files and folders of any given folder recursively ie this will fetch all the folder inside another folder and then files and show all of them one by one on the screen.

This C++ program is a part of the same compression utility, another programs of the same compression utility is as follows

The source code is

/*	Program to show files and folders of any given folder recursively
	made by		: rakesh kumar
using namespace std;
int isFile(const char* name)
    DIR* directory = opendir(name);
    if(directory != NULL) {
     return 0;
    if(errno == ENOTDIR){
     return 1;
    return -1;
void show_dir(char source[])
DIR *dir;
char name[80];
char d[80];
char ch;
struct dirent *ent;
if ((dir = opendir (source)) != NULL) {
/* print all the files and directories within directory */
while((ent = readdir (dir)) != NULL) {
if(isFile(name)==0) {

if(!((strcmp(ent->d_name,".")==0) || (strcmp(ent->d_name,"..")==0)))
else {
printf ("%s\n", ent->d_name);}
closedir (dir);
} else {
/* could not open directory */
cout<<"\n Could not open Directory";

int main(){
char source[]="C:\\wamp64\\www\\cms";
return 0;

Here is this program we have supplied a folder that is available on our hard drive. The output of the above program is as follows.
This C++ program to show files and folders was developed in windows 7 using Dev C++ IDE. if you have any better solution to the above problem then please let us know.

C++/ C program to show files and folder

Print Friendly, PDF & Email

Related Posts

If you like CBSEToaday and would like to contribute, you can also write an article using submit article or mail your article to contribute@cbsetoday.com See your article appearing on the cbsetoday.com main page and help other students/teachers.