QDir make path does not create an empty folder
-
Hello I am trying to create an empty folder. However, it does not create any folder. When I call the program first time it printed the qDebug(), but after that it does not enter to the if statement:
QString path =QDir::currentPath(); if(!QDir().exists(path)) { QDir().mkpath(path); qDebug()<<"Created"; }
When I enter some path to path manually, it always enters the if statement for the first call after that it never enters that. So I believe it creates something. But I cannot see any folder that has been created.
-
@GunkutA
Hi
mkpath makes whole path if needed - so it can also be used to create a folder.
but when you use the path currentPath();
and check if that exists, it most likely alwyas will be there so
i guess why you though it didnt work. -
@GunkutA said in QDir make path does not create an empty folder:
QString path =QDir::currentPath();
You're trying to create existing path (the current path) - how is this going to work?!
"But I cannot see any folder that has been created." - how do you check whether the path was created (on which OS, using what tool?)?
-
@GunkutA
Hi
mkpath makes whole path if needed - so it can also be used to create a folder.
but when you use the path currentPath();
and check if that exists, it most likely alwyas will be there so
i guess why you though it didnt work.