PDA

View Full Version : Copying file from resource to Program Files



ihoss
5th September 2007, 16:50
I'm trying to make a program which will install itself once run. I have everything done except copying a file from the exe's resources path to somewhere on the hard drive. This is the code I use:


QFile file
QDir::setCurrent(":/resource");
file.setFileName("lim.jar");
QDir dir;
dir.mkdir(pathLineEdit->text());
if(!file.copy(pathLineEdit->text()+"lim.jar")){
pathLineEdit->setText("could not write");
return;
}

wysota
5th September 2007, 20:33
The code doesn't seem complete...
In general you should be able to copy the file by:


QFile::copy(":/path/to/file", "C:\\....\\file");

Note that I'm using the static version of copy().

ihoss
5th September 2007, 22:31
Thanks, it worked!