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");
if(read.exists()){
qDebug()<<"True";
}
else{
qDebug()<<"False";
}return a.exec();
}
@ -
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.
-
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.