.exists method returns false for the files stored in C: [Windows]
-
Hi all, my problem is when I try to check the existence of a file stored in the C: (ex: C:\\myFile.bin), .exist method return false while the file is already exist.
What did I notice is that the method returns false when :
- The file name is composed with one letter, like : a.bin, k.bin, f.bin,..
- The file name is : Ntest.
When I change the file name to another name other than the previous examples, the method returns true , and this seems so weird.
PS:
- The files which cannot be detected, become detectable outside the C: or when they are located inside a C: folder (ex: C:\\folderName\fileName.bin).
- I am working with bin files.
- I don't have the admin rights in the env where my code is running.
The code :
QString qFilePath = QString::fromWCharArray(filePath); if(!QFileInfo(qFilePath).exists()){ return ERROR_NO_FILE; }
-
This example works fine for me with Qt 6.5 on windows 10:
#include <QtCore> int main(int argc, char** argv) { QCoreApplication app(argc, argv); if (QFile("C:\\t.bin").exists()) { qDebug() << "exists"; } else { qDebug() << "Does not exist"; } return 0; }
What Qt version and OS do you use. Please also check it with my simple example instead in your code.
-
This example works fine for me with Qt 6.5 on windows 10:
#include <QtCore> int main(int argc, char** argv) { QCoreApplication app(argc, argv); if (QFile("C:\\t.bin").exists()) { qDebug() << "exists"; } else { qDebug() << "Does not exist"; } return 0; }
What Qt version and OS do you use. Please also check it with my simple example instead in your code.
Thanks @Christian-Ehrlicher for your time, your code works fine, and mine as well; the problem was with the file path sent to the API (frontend side).