Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read file names from a directory

Tags:

c++

file

file-io

I was wondering if there's an easy way in C++ to read a number of file names from a folder containing many files. They are all bitmaps if anyone is wondering.

I don't know much about windows programming so I was hoping it can be done using simple C++ methods.

like image 944
Tony R Avatar asked Mar 04 '09 04:03

Tony R


People also ask

How do I get the filenames in a directory into text?

Right-click that folder and select Show more options. Click Copy File List to Clipboard on the classic menu. You'll still need to paste the copied list into a text file. Launch Run, type Notepad in the Open box, and click OK.


1 Answers

Boost provides a basic_directory_iterator which provides a C++ standard conforming input iterator which accesses the contents of a directory. If you can use Boost, then this is at least cross-platform code.

like image 148
chrish Avatar answered Oct 15 '22 10:10

chrish