CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2008

    Populate array with filenames from relative folder

    I need to know how I can pull filenames from a folder which is relative to the program (I change the program's location from time to time) The folder I need to look in is in the same folder as the .exe.

    When looping to get the filenames I need to check the extension of the file, and make sure it finishes with .cfg and nothing else, if it finishes with something different, ignore it.

    The filenames saved in the array should be just the name, no path, and it should not include the .cfg in it when in the array.

    An alternative method would be to do system("dir/b > files.txt") in the folder and pull the filenames line by line from the textfile, excluding anything not finishing with .cfg, if it's easier this way.

    Not too sure how to go about doing this.

  2. #2
    Join Date
    Feb 2003
    Iasi - Romania

    Re: Populate array with filenames from relative folder

    "When in Rome, do as Romans do."
    My latest articles: http://codexpert.ro/blog/author/ovidiu-cucu/

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.