#include#include int main() { QFileInfo fileInfo("path/to/file.txt"); qDebug() << "Path: " << fileInfo.filePath(); qDebug() << "Size: " << fileInfo.size() << "bytes"; qDebug() << "Last Modified: " << fileInfo.lastModified().toString("dd/MM/yyyy"); return 0; }
#includeThis code demonstrates how to use QFileInfo to obtain information about a directory. The QFileInfo object is created by passing the path to the directory as a parameter. We can then use various member functions such as isDir() and dir() to obtain the desired details about the directory. Package library: Qt.#include int main() { QFileInfo dirInfo("path/to/directory"); qDebug() << "Is Directory: " << dirInfo.isDir(); qDebug() << "Absolute Path: " << dirInfo.absoluteFilePath(); qDebug() << "Directory Name: " << dirInfo.dir().dirName(); return 0; }