Not quite, QDir::Time sorts by modification date, not creation date. You will have to read all QFileInfo's and do the comparison yourself:
foreach
(QFileInfo fileInfo, dir.
entryInfoList()) {
if (oldest.filePath().isEmpty() || fileInfo.created() < oldest.created())
{
oldest = fileInfo;
}
}
qDebug() << "Oldest file is: " << oldest.filePath();
QDir dir("d:/");
QFileInfo oldest;
foreach (QFileInfo fileInfo, dir.entryInfoList())
{
if (oldest.filePath().isEmpty() || fileInfo.created() < oldest.created())
{
oldest = fileInfo;
}
}
qDebug() << "Oldest file is: " << oldest.filePath();
To copy to clipboard, switch view to plain text mode
Bookmarks