# Listing dir

This topic is 5054 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How can I get an array of strings containing all file names inside any directory? Note: I'm using windows.

##### Share on other sites
In C++, I would just use boost::filesystem. If not C++, then you might mention what language you are using.

##### Share on other sites
This is an example from MSDN

hope that helps !
Matt

##### Share on other sites
well, i was a few minutes late in beating the MSDN example, but i came up with this:

void pwd(){	WIN32_FIND_DATA data;	HANDLE first = FindFirstFile("*.*", &data);	std::cout << data.cFileName << "\n";	while(FindNextFile(first, &data))		std::cout << data.cFileName << "\n";}

it seems to work well, and may be a little simpler to read. btw: include windows.h.

EDIT: and you would want to store in a string instead of outputting, of course.

[Edited by - anist on August 16, 2004 12:07:53 AM]

##### Share on other sites
Quote:
 Original post by anistwell, i was a few minutes late in beating the MSDN example, but i came up with this:*** Source Snippet Removed ***it seems to work well, and may be a little simpler to read. btw: include windows.h.EDIT: and you would want to store in a string instead of outputting, of course.

Wow, im going to use that. May way was so much more complicated.

Thanks

• 34
• 12
• 10
• 9
• 9
• ### Forum Statistics

• Total Topics
631354
• Total Posts
2999505
×