美文网首页
使用QFileInfo获取文件路径和名称

使用QFileInfo获取文件路径和名称

作者: NullUser | 来源:发表于2024-07-31 14:51 被阅读0次
    QFileInfo fileInfo("E:/temp/myfile.tar.txt");
    qDebug() << "path:" << fileInfo.path();
    qDebug() << "filePath:" << fileInfo.filePath();
    qDebug() << "absolutePath:" << fileInfo.absolutePath();
    qDebug() << "absoluteFilePath:" << fileInfo.absoluteFilePath();
    qDebug() << "fileName:" << fileInfo.fileName();
    qDebug() << "baseName:" << fileInfo.baseName();
    qDebug() << "completeBaseName:" << fileInfo.completeBaseName();
    qDebug() << "suffix:" << fileInfo.suffix();
    qDebug() << "completeSuffix:" << fileInfo.completeSuffix();

输出:

path: "E:/temp"
filePath: "E:/temp/myfile.tar.txt"
absolutePath: "E:/temp"
absoluteFilePath: "E:/temp/myfile.tar.txt"
fileName: "myfile.tar.txt"
baseName: "myfile"
completeBaseName: "myfile.tar"
suffix: "txt"
completeSuffix: "tar.txt"

相关文章

网友评论

      本文标题:使用QFileInfo获取文件路径和名称

      本文链接:https://www.haomeiwen.com/subject/zzenhjtx.html