Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read All Files in Directory?

Tags:

c++

file-io

How would I go about reading all files in a directory?

In C# I would get a DirectoryInfo object, and get all files into a FileInfo[] object.

Is there similar functionality in the STD namespace in C++?

like image 692
cam Avatar asked Apr 28 '10 18:04

cam


People also ask

How do I read all files in a directory in Python?

To get a list of all the files and folders in a particular directory in the filesystem, use os. listdir() in legacy versions of Python or os. scandir() in Python 3.


2 Answers

For a free, portable solution try the Boost Filesystem Library.

like image 148
Fred Larson Avatar answered Oct 08 '22 13:10

Fred Larson


Using Windows API, you can find all the files in a directory using FindFirstFile() with FindNextFile() in a loop.

like image 20
cpx Avatar answered Oct 08 '22 11:10

cpx