Checking for existing .exe file

  • 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");

    return a.exec(&#41;;


  • 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.

  • Lifetime Qt Champion


    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.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.