reference:
Thank you very much for your article! ! !
experiment:
//D:/aA:存在
//D:/a:不存在
//D:/1/1.txt:存在
//D:/1/2.txt:不存在
QFileInfo info("D:/aA");
qDebug()<<info.isDir();
QFileInfo info1("D:/a");
qDebug()<<info1.isDir();
QFileInfo info2("D:/1/1.txt");
qDebug()<<info2.isFile();
QFileInfo info3("D:/1/2.txt");
qDebug()<<info3.isFile();
result:
true
false
true
false
Summarize:
(1) I want to know whether the path exists, it doesn’t matter whether it is a file or a folder.
QFileInfo::exists()
(2) Want to know if path is a folder
QFileInfo::isDir()
(3) Want to know if path is a file
QFileInfo::isFile()