Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Executable file path only
Forum Update on Monday, May 27th 2025

Executable file path only

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 3.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Parthasaradhi
    wrote on 27 Sept 2019, 03:03 last edited by
    #1

    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.

    J 1 Reply Last reply 27 Sept 2019, 03:45
    0
    • P Parthasaradhi
      27 Sept 2019, 03:03

      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.

      J Offline
      J Offline
      JKSH
      Moderators
      wrote on 27 Sept 2019, 03:45 last edited by
      #2

      @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();

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      4
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 27 Sept 2019, 04:34 last edited by
        #3

        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.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        P 1 Reply Last reply 27 Sept 2019, 05:50
        7
        • S SGaist
          27 Sept 2019, 04:34

          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.

          P Offline
          P Offline
          Parthasaradhi
          wrote on 27 Sept 2019, 05:50 last edited by
          #4

          @SGaist Thank you. Yes I got it.

          1 Reply Last reply
          0

          1/4

          27 Sept 2019, 03:03

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved