Listing dir

Started by
3 comments, last by Mulligan 19 years, 8 months ago
How can I get an array of strings containing all file names inside any directory? Note: I'm using windows.
Advertisement
In C++, I would just use boost::filesystem. If not C++, then you might mention what language you are using.
This is an example from MSDN

hope that helps !
Matt

edit: fixed the link
Matt
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]
As your leader, I encourage you from time to time, and always in a respectful manner, to question my logic. If you're unconvinced that a particular plan of action I've decided is the wisest, tell me so, but allow me to convince you and I promise you right here and now, no subject will ever be taboo. Except, of course, the subject that was just under discussion. The price you pay for bringing up either my Chinese or American heritage as a negative is - I collect your f***ing head.
Quote:Original post by anist
well, 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

This topic is closed to new replies.

Advertisement