zoukankan      html  css  js  c++  java
  • [QT学习]拷贝文件

    sourceDir源绝对路径,toDir目标绝对路径

     1 //拷贝文件:
     2 bool FileOperation::copyFileToPath(QString sourceDir ,QString toDir, bool coverFileIfExist)
     3 {
     4     toDir.replace("\","/");
     5     if (sourceDir == toDir){
     6         return true;
     7     }
     8     if (!QFile::exists(sourceDir)){
     9         return false;
    10     }
    11     QFileInfo fi(toDir);
    12     QString dirPath=fi.absolutePath();//取路径
    13     QDir *createfile = new QDir;
    14     bool exist=createfile->exists(dirPath);
    15     if(!exist)
    16     {
    17         createfile->mkdir(dirPath);
    18     }
    19     exist = createfile->exists(toDir);
    20     if (exist){
    21         if(coverFileIfExist){
    22             createfile->remove(toDir);
    23         }
    24     }//end if
    25 
    26     if(!QFile::copy(sourceDir, toDir))
    27     {
    28         return false;
    29     }
    30     return true;
    31 }
  • 相关阅读:
    多线程 介绍
    AE中如何获取曲线的一部分(转)
    friday
    THU
    MON
    SAT
    周三
    TUE
    绝对遗憾!
    monday
  • 原文地址:https://www.cnblogs.com/zhaotian/p/5424100.html
Copyright © 2011-2022 走看看