PDA

View Full Version : copy Files



mouni
11th June 2015, 12:19
Hi friends,


How to copy a file from one directory to another

yeye_olive
11th June 2015, 14:55
QFile::copy().

mouni
12th June 2015, 05:39
it is not working...
QFile::copy(qApp->applicationDirPath(),"E:\\projects_Qt_main\\ISRO_SAC\\Data_Encode_Decode \\DataEncoder\\File_Receiver_Transmitter -\\Added");

Added is the folder to copy file.....

rawfool
12th June 2015, 05:53
The syntax is
QFile::copy("/path/fileName", "/newPath/fileName");
Check your arguments, also check the return value.
qfile.html#copy-2

Radek
12th June 2015, 07:41
(1) You need to copy a file to a file. Your first argument is a directory, not a file.
(2) Note that copy() does not overwrite. If the target file exists, nothing will be copied and you get false in return. If you need overwriting, delete the target file first.
(3) In Qt, use forward slashes, even in windows. Therefore: "E:/projects_etc/and_so_on"