-
-
Save mozzbozz/2e83d7e3452a07fa817980403c42eade to your computer and use it in GitHub Desktop.
Additional code for clarification in reply to a comment ( https://stackoverflow.com/questions/10273816/how-to-check-whether-file-exists-in-qt-in-c/26991243?noredirect=1#comment86989399_26991243 )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QString path = "C:/test.pdf"; // this path points to an existing file | |
bool fileExists = QFileInfo::exists(path); | |
qDebug() << fileExists; // true | |
// this path points to an existing directory | |
// (Caution: we want to check for a file, not a directory!) | |
path = "C:/Users"; | |
fileExists = QFileInfo::exists(path); | |
qDebug() << fileExists; // true (this is NOT what we want!) | |
path = "C:/non_existing_file.txt"; // this path points to no actual file | |
fileExists = QFileInfo::exists(path); | |
qDebug() << fileExists; // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment