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
    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
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: Populate array with filenames from relative folder

    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

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