zoukankan      html  css  js  c++  java
  • QDir路径的测试与创建-QT

    #include <QCoreApplication>
    #include <QDir>
    #include<QtDebug >
    #include<QFileInfo>
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
        //测试文件路径是否存在
        QDir mDir("E:/Testa");
        qDebug()<<mDir.exists();
    
        //测试有几个分区
        QDir mDir1;
        foreach(QFileInfo mItm,mDir.drives())
        {
            qDebug() <<mItm.absoluteFilePath();
        }
    
        //查看路径是否存在,若不存在,就建立该路径
        QDir mDir2;
        QString mPath("E:/a/a01.txt");
        if(!mDir2.exists(mPath))
        {
            mDir2.mkpath(mPath);
            qDebug()<<"Created";
        }
        else
        {
            qDebug()<<"Alreadt exists.";
        }
    
        //测试给定路径中文件夹
        QDir mDir3("E:/Test");
        foreach (QFileInfo mitm,mDir3.entryInfoList()) {
            qDebug()<<mitm.absoluteFilePath();
            
            if(mitm.isDir())
                qDebug() <<"Dir: "<<mitm.absoluteFilePath();
            if(mitm.isFile())
                qDebug() <<"File: "<<mitm.absoluteFilePath();
        }
    
        return a.exec();
    }
    

      

  • 相关阅读:
    jQuery事件
    jQuery的效果
    jQuery 选择器
    中级 jQuery 了解
    回调函数 callback()
    预加载
    表格对象的方法
    script中type属性讲解
    将数据渲染到页面的方式:模版
    将数据渲染到页面的几种方式
  • 原文地址:https://www.cnblogs.com/my-cat/p/6112150.html
Copyright © 2011-2022 走看看