Here’s a code snippet that works fine provided the destinationFile doesn’t exist:
QFile destinationFile, sourceFile;
QDir destination("../CopiedFiles");
QString fileName("MyData.dat");
destinationFile.setFileName(destination.filePath(fileName));
sourceFile.setFileName("../MainData/" + fileName);
sourceFile.copy(destinationFile.fileName());
Is there any way to overwrite the file automatically, or would I have to go the long way around (checking if the destinationFile exists, and if it does, removing it and then copying)?
↧