PDA

View Full Version : QDir create multiple dirs



^NyAw^
4th March 2009, 10:50
Hi,

Can QDir create a directory with sub directories?

I have "/data" and I want to create "/data/dir1/subdir1"

Is there a way to create "dir1" and "subdir1" at same time or have I to create one by one?

Thanks,

vcp
4th March 2009, 11:42
Hi,

See my tests:

QDir dir;

First Case: OK: The subdir test1 will be created successfully
if( !dir.mkdir("/root/test1") )
qDebug("error);
else
qDebug("ok"); // <<---- OK

Second Case: NO: The subdir test2 will not create successfully
if( !dir.mkdir("/root/test1/test2") )
qDebug("error); // <<--- ERROR
else
qDebug("ok");

Then I think that from the second level will have of to be created manually

caduel
4th March 2009, 12:13
have a look at QDir::mkpath()