You are here:

C/Opening a folder

Advertisement


Question
Hi,
I need to open a folder and read all the listed files. How to do using C.
Thanks
Govind


Answer
Hi Govind

Check this out this may help you

#include <stdio.h>
#include<conio.h>
#include <dir.h>

void main(void)
{
  struct ffblk ffblk;
  int done, count=0;
  char ch;
  clrscr();
  printf("Directory listing of all files::\n");
  done = findfirst("*.*",&ffblk,0);
  while (!done)
  {
    printf("\n\t  %s", ffblk.ff_name);
    done = findnext(&ffblk);
    if(++count%10==0)
    {
     printf("\n\n\tPress Enter to continue listing any other key to quit: ");
     ch = getche();
     if(ch!='\r')
        break;
     else
        printf("\n\n");
    }
  }
}

In case of any clarification please feel free to revert back to me

regards
Joydeep Bhattacharya

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Joydeep Bhattacharya

Expertise

Ability to solve C and Data Structure problems and puzzles with simple and easy to understand logic.

Experience

C, C++, Java, Data Structure, PHP, Web Designing

Organizations
http://www.scodz.com Designation: webmaster

Publications
http://www.scodz.com

Education/Credentials
Master of Computer Applications

Past/Present Clients
http://analysingc.50webs.com http://www.funforu.com

©2012 About.com, a part of The New York Times Company. All rights reserved.