PDA

View Full Version : Saving Files in the applicationDirPath/Uninstalling with InnoSetup



mikrocat
27th October 2015, 06:30
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.

QFile passwordfile(QString("%1%2")
.arg(QCoreApplication::applicationDirPath())
.arg(password.txt));
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\MYAPP" 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

anda_skoa
27th October 2015, 07:48
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).



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\MYAPP" because my program has no permission to create them in the applicationDirPath.

Exactly.



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.



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.



- Getting Permission to save the files in the actual applicationDirPath

Running an end user program with elevated priviledges is always a bad idea.

Cheers,
_

mikrocat
27th October 2015, 08:31
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.