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. Checking for existing .exe file

Checking for existing .exe file

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.1k Views 1 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.
  • R Offline
    R Offline
    Raminlich
    wrote on last edited by
    #1

    Hi
    why when i want to check .exe file this program will print false but when i add .txt file and check prints True?
    i mean its only recognize .txt file not .exe.
    @#include <QCoreApplication>
    #include <QFile>
    #include <QDebug>
    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);
    QFile read("C:\Users\Ramin\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\Time.exe");
    if(read.exists()){
    qDebug()<<"True";
    }
    else{
    qDebug()<<"False";
    }

    return a.exec(&#41;;
    

    }
    @

    1 Reply Last reply
    0
    • IamSumitI Offline
      IamSumitI Offline
      IamSumit
      wrote on last edited by
      #2

      Hi.
      Are you sure the path that you have passed into QFile constructor is correct.
      May it is file problem .
      just recheck path,file name etc .again.
      also check in different drives.

      BTW.Your code is correct.

      Be Cute

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        It's also very unlikely that you have an executable file in that folder. You should rather have a symbolic link to that executable located in e.g. Program Files or Program File (x86)

        On a side note, since you are using Qt, you can (and should) use the forward slash unix notation, it's less error prone.

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

        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