Copying the file content
-
Hi,
@suslucoder said in Copying the file content:
QFile::copy("C:/Users/ilknu/Documents/MyThread/deneme.txt","C:/Users/ilknu/Documents/MyThread/new.txt" );
qDebug() << QFile::copy("C:/Users/user/Documents/MyThread/deneme.txt", "C:/Users/user/Documents/MyThread/new.txt");You do not have the same paths in the qDebug and the previous line.
You do realise that you are copying it twice ? -
@suslucoder said in Copying the file content:
They exists.
And? We have all said
QFile::copy()
says:Note that if a file with the name newName already exists, copy() returns false (i.e. QFile will not overwrite it).
So you (not we) need to do something about that.
Also, as @SGaist has pointed out, you don't even have the same paths on your two
QFile::copy()
calls. -
Then the cause is clear: destination exists, so copy() will not overwrite it. You need to remove the destination file first, before calling copy().
-
@JonB said in Copying the file content:
Also, as @SGaist has pointed out, you don't even have the same paths on your two
QFile::copy()
calls. I've fixed it, it is my mistake.Even i delete the destination file, for returning true by creating new destination, it returns false.
-
@suslucoder Did you check what @SGaist said? Do NOT call copy twice! Call it once like before but put qDebug() in front of it...
-
@suslucoder it works. thank you