gpt4 book ai didi

c++ - QFileInfo 所有者和组为空

转载 作者:行者123 更新时间:2023-11-28 06:07:37 27 4
gpt4 key购买 nike

这是我的位置:

void MainWindow::writeOnFile(const QString &path)
{
// Get info files :
QFileInfo fileInfo(path);
QString name = fileInfo.fileName();
QString lastModif = fileInfo.lastModified().toString();
QString owner = fileInfo.owner();
QString group = fileInfo.group();
QString lastRead = fileInfo.lastRead().toString();
QString created = fileInfo.created().toString();


// Write on Logs :
QString filename = "C:\\Users\\Sherlock\\Desktop\\logs.txt";
QFile file ( filename );
if ( file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text) )
{
QTextStream stream( &file );
stream << "The file " << name
<< " was first created on " << created
<< ", was last read on " << lastRead
<< " and was last modified on " << lastModif
<< ". The owner is " << owner
<< ". The group is " << group
<< endl;
}
}

这是我的输出:

The file younes.txt was first created on lun. août 17 19:40:34 2015, was last read on lun. août 17 19:40:34 2015 and was last modified on mar. août 18 00:21:51 2015. The owner is . The group is

如您所见,未显示所有者

我做错了什么吗?

最佳答案

On Windows [...] an empty string is returned.

因此,据记载 group() 以这种方式工作。

关于c++ - QFileInfo 所有者和组为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32061352/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com