Getting all file names in current directory

Oct 31, 2012 at 6:48am
Hey all, just wondering if you could give me a hand figuring our directories in c++.

Basically what I plan on making is a program that will ask you which program extension you're looking for (ie .docx, .cpp, .txt) then it will search the directory for all files with that extension, return those to the user and allow the user to choose which file they want to open. I'm fairly certain I know how to get the extension off of a string. As well as being able to put file names into a vector of strings to accomplish the final task, however I'm unsure of how to go about getting the file names.

The directory used will simply be the directory that the .exe is in, no need to get it as input. I also want to accomplish this using only the C++ standard library. I've done some searching for examples and I've found stuff that is either using a directory it gets as input, or is using things like <dirent.h>

If you guys could give me a simple push in the right direction on how I might be able to start this it would be greatly appreciated!

Thanks!

-Sh0
Last edited on Nov 1, 2012 at 2:34am
Oct 31, 2012 at 6:52am
C++ has no concept of directories. So you won't accomplish this "using only the C++ standard library." You need to use OS specific methods or libraries that will do the OS specific things for you.
Nov 1, 2012 at 2:00am
My mistake, going off of:
http://msdn.microsoft.com/en-us/library/aa365200%28v=vs.85%29.aspx

I thought all of those includes were part of the standard library as they would work without need to download any new libraries.

I suppose my question should be how I would go about accomplishing this task using the includes that are used in that link ^.
Topic archived. No new replies allowed.