CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2009
    Posts
    12

    [RESOLVED] Find directories

    Hi Guys,

    I am new to c++ and win32.
    I want to quickly write code to find all subdirectories within a given directory
    and store these as a tchar array.

    Can you please help me ?

    Thanks a lot.

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Find directories

    You could try the FindFirstFile and FindNextFile functions

  3. #3
    Join Date
    May 2007
    Posts
    437

  4. #4
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Find directories

    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  5. #5
    Join Date
    Jun 2009
    Posts
    12

    Re: Find directories

    Thanks a lot guys, but I need to find only the folder names and create an array of them .

    I do not need to find the files inside each folder.

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: Find directories

    Quote Originally Posted by harsh_1986 View Post
    Thanks a lot guys, but I need to find only the folder names and create an array of them .

    I do not need to find the files inside each folder.
    The answer is in this thread. Did you read the links you were provided?

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Find directories

    Then use CFileFind::IsDirectory (in case of MFC) or GetFileAttributes API) to check if the file is directory.
    Victor Nijegorodov

  8. #8
    Join Date
    Jun 2009
    Posts
    12

    Re: Find directories

    I found one where I have to create a CstringArray but mine is not an MFC.
    I am confused what all to include.

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: [RESOLVED] Find directories

    You could use std::vector instead.
    Victor Nijegorodov

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