#include#include int main() { QDir dir("/path/to/directory"); foreach (QFileInfo fileInfo, dir.entryInfoList()) { qDebug() << fileInfo.fileName(); // print the file/directory name } return 0; }
#includeint main() { QDir dir("/path/to/new/directory"); if (!dir.exists()) { dir.mkdir("."); // create the directory } return 0; }
#includeThese examples demonstrate how QDir can be used to manipulate directories and files in C++ programs. The package library for QDir is the Qt library.int main() { QDir dir("/path/to/file"); if (dir.exists()) { dir.remove("."); // delete the file } return 0; }