Qt World Summit: Register Today!

QFile::copy() failing...

  • Hi,

    I am currently trying to use QFile's copy method to copy an executable from one location to another in an updater application I have created.

    The first thing I do is remove the destination file, then I copy the source to the destination...like so:
    // check if the file exists and remove it
    if (QFile(destination).exists())

    // copy the file
    if (!QFile::copy(source, destination)){
        // always goes into here


    where source = C:\jobs\file1.exe
    and destination = C:\updatev1\file1.exe

    I feel like this should be a simple task but I keep getting a false return from the copy?
    (I know the files are getting removed successfully as well, I have quadruple double checked that they are)

    Why ideas?

  • What's the return value of QFile::remove()? Are you really sure, it is removed. Do you try to replace the currently running executable?

Log in to reply