#include#include int main() { QFileInfo fileInfo("myfile.txt"); qDebug() << "File size:" << fileInfo.size() << "bytes"; return 0; }
#includeIn this example, a list of file paths is created. The QFileInfo object is created for each file path in the loop. The isDir() function is called to check if the file is a directory or not. Package: Qt Core library.#include int main() { QStringList files {"myfile.txt", "mydir"}; for (const QString& file : files) { QFileInfo fileInfo(file); if (fileInfo.isDir()) { qDebug() << file << "is a directory"; } else { qDebug() << file << "is not a directory"; } } return 0; }