Populate array with filenames from relative folder
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Populate array with filenames from relative folder

  1. #1
    Join Date
    Nov 2008
    Posts
    3

    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
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,051

    Re: Populate array with filenames from relative folder

    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: 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

This is a CodeGuru survey question.


Featured


HTML5 Development Center