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 Updated to NodeBB v4.3 + New Features

Executable file path only

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 3.7k Views 3 Watching
  • 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 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.

    JKSHJ 1 Reply Last reply
    0
    • P Parthasaradhi

      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.

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on 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
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on 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
        7
        • SGaistS SGaist

          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 last edited by
          #4

          @SGaist Thank you. Yes I got it.

          1 Reply Last reply
          0

          • Login

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