Skip to content

Instantly share code, notes, and snippets.

@mozzbozz
Created April 30, 2018 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mozzbozz/2e83d7e3452a07fa817980403c42eade to your computer and use it in GitHub Desktop.
Save mozzbozz/2e83d7e3452a07fa817980403c42eade to your computer and use it in GitHub Desktop.
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