|
-
January 19th, 2011, 12:06 PM
#2
Re: list all files in a directory c++
What do you mean by "best"? The code you have posted will work on any system that recognises the DIR command in the shell (once you solve that string to char* problem). Which, I think, is windows.
The last time I had to do this, I used the dirent.h header file and the readdir function, but dirent.h is POSIX and isn't part of windows.
I think windows makes use of FindFirstFile and FindNextFile to do something similar.
What happens if you try to build that system command in pieces?
Something like:
Code:
std::string commandPart;
commandPart = ExePath();
std::string command("DIR ");
command = command + commandPart;
const char* command_cStr = command.c_str();
system(command_cStr);
Last edited by Moschops; January 19th, 2011 at 12:12 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|