CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2010
    Posts
    38

    List out all the files in a folder

    Could anyone tell me how to list out all the files in a folder?
    e.g. if I want to extract all the .jpeg files from a folder, how do i go about it?

    Any help would be appreciated.

    Thanks

  2. #2
    Join Date
    Aug 1999
    Location
    Darmstadt, FRG
    Posts
    87

    Re: List out all the files in a folder

    The CFileFind-class (of MFC) might be aqppropriate.

  3. #3
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: List out all the files in a folder

    It's OS-specific, unless you use a cross-platform library like Boost.Filesystem. What OS are you on?

  4. #4
    Join Date
    Oct 2010
    Posts
    38

    Re: List out all the files in a folder

    I am using Windows although I would be happy to port to Linux too.

    And is there some Non-MFC alternative?

    Thanks

  5. #5
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: List out all the files in a folder

    Look up FindFirstFile and FindNextFile on MSDN.

  6. #6
    Join Date
    Oct 2010
    Posts
    38

    Re: List out all the files in a folder

    Thanks A Lot!

    Although ,it does not search directory within a directory.

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

    Re: List out all the files in a folder

    Quote Originally Posted by vinayak4gargya View Post
    Thanks A Lot!

    Although ,it does not search directory within a directory.
    It does if you call it recursively. There are examples in the FAQ.

  8. #8
    Join Date
    Oct 2010
    Posts
    38

    Re: List out all the files in a folder

    Yep got it!
    Supposed to AND FileAttributes with FILE_ATTRIBUTE_DIRECTORY

    Thanks a bunch

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