Checking if a folder exists (and creating folders) in Qt, C++
Checking if a folder exists (and creating folders) in Qt, C++
The following “Folder” exists :
QDir("Folder").exists();
Create a new folder named as”MyFolder” :
QDir().mkdir("MyFolder");
The following solution is exists and it does not including intermediaries:
QDir dir("path/to/dir"); if (!dir.exists()) dir.mkpath(".");
The best solution is:
To use QDir.mkpath() it returns true if the path already exists, in the other hand QDir.mkdir() returns false if the path already exists. So depending on this program have to choose which fits better.