Results 1 to 3 of 3

Thread: Copying file from resource to Program Files

  1. #1
    Join Date
    Aug 2007
    Posts
    39
    Thanks
    8

    Default Copying file from resource to Program Files

    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:
    Qt Code:
    1. QFile file
    2. QDir::setCurrent(":/resource");
    3. file.setFileName("lim.jar");
    4. QDir dir;
    5. dir.mkdir(pathLineEdit->text());
    6. if(!file.copy(pathLineEdit->text()+"lim.jar")){
    7. pathLineEdit->setText("could not write");
    8. return;
    9. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Copying file from resource to Program Files

    The code doesn't seem complete...
    In general you should be able to copy the file by:

    Qt Code:
    1. QFile::copy(":/path/to/file", "C:\\....\\file");
    To copy to clipboard, switch view to plain text mode 

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

  3. The following user says thank you to wysota for this useful post:

    ihoss (5th September 2007)

  4. #3
    Join Date
    Aug 2007
    Posts
    39
    Thanks
    8

    Default Re: Copying file from resource to Program Files

    Thanks, it worked!

Similar Threads

  1. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  2. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 04:19
  3. Replies: 5
    Last Post: 22nd September 2006, 08:04
  4. Replies: 2
    Last Post: 13th September 2006, 09:11
  5. [Win32/VC++ 8.0] Strange problems with qrc_*.cpp files
    By mloskot in forum Installation and Deployment
    Replies: 6
    Last Post: 6th March 2006, 10:28

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.