CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2002
    Location
    Princeton, NewJersey, US
    Posts
    817

    Count no.of files in a folder.?

    Hi ALL.,

    How can I retrive the no. of files and it's name available in a folder.?

    Thanks..!
    GOOD DAY..!

    NICK.

    E-MAIL : [email protected]

  2. #2
    Join Date
    Aug 1999
    Location
    Wisconsin
    Posts
    507
    Here's a short example that lists all files in the
    current working directory. You can modify it easily for
    your purpose:

    Code:
    {
       CFileFind finder;
       char szDir[MAX_PATH+1];
       GetCurrentDirectory(MAX_PATH,szDir);
       strcat(szDir,"\\*.*");
       cout << "Dire=" << szDir << endl;
       BOOL bWorking = finder.FindFile(szDir);
       while (bWorking)
       {
          bWorking = finder.FindNextFile();
    	  // Don't list directory names
    	  if(!finder.IsDirectory())  
    	  {
              cout << (LPCTSTR)finder.GetFilePath() << endl;
    	  }
       }
    
       return 0;
    }

  3. #3
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

  4. #4
    Join Date
    Jul 2002
    Location
    Princeton, NewJersey, US
    Posts
    817
    Thanks a lot Kochhar & Andreas for yoru replies..

    I got it..
    GOOD DAY..!

    NICK.

    E-MAIL : [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured