Results 1 to 3 of 3

Thread: Saving Files in the applicationDirPath/Uninstalling with InnoSetup

  1. #1
    Join Date
    Oct 2015
    Posts
    50
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Saving Files in the applicationDirPath/Uninstalling with InnoSetup

    Hi,

    in my Project i create a file where i save a (encrypted) password. So the user doesnt need to enter it on the next run of the program.
    Qt Code:
    1. QFile passwordfile(QString("%1%2")
    2. .arg(QCoreApplication::applicationDirPath())
    3. .arg(password.txt));
    To copy to clipboard, switch view to plain text mode 
    As you can see I want to save the file in the directory of my application exe.
    If I do a setup with InnoSetup and save the Programm in "C:\Program Files (x86)\MYAPP", the files I create in my app are located in
    "C:\Users\MYUSERNAME\AppData\Local\Programs\MY APP" because my program has no permission to create them in the applicationDirPath.
    I want to delete the files with uninstalling the program so it would be much easier for me to have them in the applicationDirPath.

    I'm open-minded for different ideas
    - Another way to save the password (maybe not in an extra file!?)
    - Getting Permission to save the files in the actual applicationDirPath
    - Track the files with InnoSetup and uninstall them

    Thank your for Your attention,
    mikrocat

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Saving Files in the applicationDirPath/Uninstalling with InnoSetup

    Quote Originally Posted by mikrocat View Post
    As you can see I want to save the file in the directory of my application exe.
    As you found out that is a terrible idea.
    Resources in applicationDirPath() need to be considered read-only unless the program explicitly requires to be installed in a user directory (and it is still I bad idea then).

    Quote Originally Posted by mikrocat View Post
    If I do a setup with InnoSetup and save the Programm in "C:\Program Files (x86)\MYAPP", the files I create in my app are located in
    "C:\Users\MYUSERNAME\AppData\Local\Programs\MY APP" because my program has no permission to create them in the applicationDirPath.
    Exactly.

    Quote Originally Posted by mikrocat View Post
    I want to delete the files with uninstalling the program so it would be much easier for me to have them in the applicationDirPath.
    That sounds very user unfriendly. A user could then not simply reinstall the application but would have to re-setup it as well.

    Quote Originally Posted by mikrocat View Post
    I'm open-minded for different ideas
    - Another way to save the password (maybe not in an extra file!?)
    QSettings or using QStandardPaths to locate a writable location.

    Quote Originally Posted by mikrocat View Post
    - Getting Permission to save the files in the actual applicationDirPath
    Running an end user program with elevated priviledges is always a bad idea.

    Cheers,
    _

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

    mikrocat (27th October 2015)

  4. #3
    Join Date
    Oct 2015
    Posts
    50
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Saving Files in the applicationDirPath/Uninstalling with InnoSetup

    Quote Originally Posted by anda_skoa View Post
    QSettings or using QStandardPaths to locate a writable location.
    Thank You for Your answer. I will take a look at the QSettings class and might come up with a new question.
    This class sounds very useful and I think it will solve my problem.

Similar Threads

  1. Saving / Loading Files
    By nightroad in forum Qt Programming
    Replies: 3
    Last Post: 26th August 2011, 14:13
  2. Prevent saving files to System folders
    By ScottBrady in forum Newbie
    Replies: 8
    Last Post: 13th August 2011, 16:19
  3. Problem when saving bmp files
    By cdlaweed in forum Newbie
    Replies: 3
    Last Post: 17th March 2011, 10:20
  4. Replies: 2
    Last Post: 14th November 2010, 12:14
  5. uninstalling Qt 3.1 and loading qt4.4.3
    By Amrita Singh in forum Installation and Deployment
    Replies: 7
    Last Post: 15th May 2010, 15:50

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.