#include <QApplication>
#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include <QString>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QDir dir(".");
qDebug() << dir.exists();
QDir dir2("/home/zxw");
qDebug() << dir2.exists();
QDir dir3("/home/zxw/Desktop/mytest/123");
qDebug() << dir3.exists();
QDir dir4;
foreach(QFileInfo item, dir4.drives())
{
qDebug() << item.absoluteFilePath();
}
QDir dir5;
QString dirPath("/home/zxw/Desktop/mytest/123");
if(!dir5.exists(dirPath))
{
dir5.mkpath(dirPath);
qDebug() << "Created.";
}
else
{
qDebug() << "Already exist.";
}
QDir dir6("/home/zxw/Desktop/mytest");
foreach(QFileInfo item, dir6.entryInfoList())
{
if(item.isDir())
qDebug() << "Dir: " << item.absoluteFilePath();
else if(item.isFile())
qDebug() << "File: " << item.absoluteFilePath();
else
qDebug() << "Others.";
}
return a.exec();
}
#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include <QString>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QDir dir(".");
qDebug() << dir.exists();
QDir dir2("/home/zxw");
qDebug() << dir2.exists();
QDir dir3("/home/zxw/Desktop/mytest/123");
qDebug() << dir3.exists();
QDir dir4;
foreach(QFileInfo item, dir4.drives())
{
qDebug() << item.absoluteFilePath();
}
QDir dir5;
QString dirPath("/home/zxw/Desktop/mytest/123");
if(!dir5.exists(dirPath))
{
dir5.mkpath(dirPath);
qDebug() << "Created.";
}
else
{
qDebug() << "Already exist.";
}
QDir dir6("/home/zxw/Desktop/mytest");
foreach(QFileInfo item, dir6.entryInfoList())
{
if(item.isDir())
qDebug() << "Dir: " << item.absoluteFilePath();
else if(item.isFile())
qDebug() << "File: " << item.absoluteFilePath();
else
qDebug() << "Others.";
}
return a.exec();
}