Executable file path only
-
wrote on 27 Sept 2019, 03:03 last edited by
Hi all,
I would like to create a data file in the same folder as the executable is in. When I use available path options with Qstring, I am getting the path but at the end of the string, my executable file name is attached. What I need is just the path to the folder, so I can append the new file name that I would like to create/open/read/write to this path. Any help will be greatly appreciated. Thank you for your time. -
Hi all,
I would like to create a data file in the same folder as the executable is in. When I use available path options with Qstring, I am getting the path but at the end of the string, my executable file name is attached. What I need is just the path to the folder, so I can append the new file name that I would like to create/open/read/write to this path. Any help will be greatly appreciated. Thank you for your time.@Parthasaradhi said in Executable file path only:
What I need is just the path to the folder
https://doc.qt.io/qt-5/qfileinfo.html#dir
QDir appFolder = QFileInfo("/path/to/application.exe").dir();
-
Hi,
You can use QCoreApplication::applicationDirPath. However beware that if your user install your application it will likely be in a read-only location so handling of that file will file. You should consider using QStandardPaths to get a suitable location for your application data to be stored cross platform.
-
Hi,
You can use QCoreApplication::applicationDirPath. However beware that if your user install your application it will likely be in a read-only location so handling of that file will file. You should consider using QStandardPaths to get a suitable location for your application data to be stored cross platform.
wrote on 27 Sept 2019, 05:50 last edited by@SGaist Thank you. Yes I got it.
1/4