标签:note 创建目录 color text AC item debug 文件夹路径 absolute
1. YT_11_QDir
#include <QCoreApplication> #include<QDir> #include<QFileInfo> #include<QString> #include<QDebug> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QDir mDir; //foreach (QFileInfo mItem, mDir.drives() ) // qDebug() << mItem. absoluteFilePath(); QString mPath = "C:/text/ggg"; if(!mDir.exists(mPath)) { mDir.mkpath(mPath); } else { qDebug() << "Already exists."; } return a.exec(); }
创建目录 C:/text/ggg,如果目录不存在就创建它。
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QDir mDir("C:/Program Files"); foreach(QFileInfo mItem, mDir.entryInfoList()) qDebug() << mItem.absoluteFilePath(); return a.exec(); }
获取指定路径下的全部文件夹路径作为列表,并输出该列表。
标签:note 创建目录 color text AC item debug 文件夹路径 absolute
原文地址:https://www.cnblogs.com/TadGuo/p/8999092.html