+ 3
How do I open a directory in c++
I've been reading about the <fstream> lately, I read a lot about but I never even a word talking about directories, I read all about files. now I want to open a directory but I just can't.
9 Answers
+ 5
@Luyanda
A pure windows version đ...
https://code.sololearn.com/cHuxY17co2X2/?ref=app
This may help you.
It gets the list of readable folders, their size and number of files inside them, in a path entered by a user.
Eg Entering C:\\ returns the data of the folders present in C drive of the computer
(Counts only the folders)
+ 4
DIR *d;
d = opendir(path);
+ 4
You can use function opendir to open directory. On the 'path' place of my example, you need to use pointer to a character array, with the path to directory you need to open. You need include
dirent.h lib for using this function.
+ 4
@Luyanda
No, Im afraid not.
I will work on a linux version, but just can't get the time.
I have so much to learn in linux...
Windows.h is not at all cross- platform, and I can't see ncurses in CppDroid...
+ 3
What do you mean by opening a directory? Do you want to open a file in a specific directory?
+ 2
@shaldem.
thanks a lot. let me try now.
+ 2
@kishuk
thanks
will this code run on CppDroid?
+ 1
@shaldem
can you plz explain more
+ 1
@Lukas klose.
I want to open my storage disc and see the folder names using CPP.