Qt – copy a file from one directory to another

Qt – copy a file from one directory to another

Asked on January 7, 2019 in Qt.
Add Comment


  • 2 Answer(s)

    To copy a file from one directory to another:

    Try this link :   QFile 

    QFile::copy("/path/file", "/path/copy-of-file");
    
    
    Answered on January 7, 2019.
    Add Comment

    The alternative answer is:

      The  continues files of  QFile::copy will not be work to verify  the  target of  file continues and to remove it:

    if (QFile::exists("/path/copy-of-file"))
    {
        QFile::remove("/path/copy-of-file");
    }
     
    QFile::copy("/path/file", "/path/copy-of-file");
    

     

    Answered on January 7, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.