QDir has two versions of exists function that check if a folder exists:
QDir("a/b").exists();
QDir().exists("a/b");
There is a little difference between the two functions. If a is a directory and b is a sub-directory under a, both functions return true; If a is a folder and b is an ordinary file in a, QDir(“a/b”).exists() returns false but QDir().exists(“a/b”) returns true. So, to check if a directory exists, you’d better use QDir(“a/b”).exists(). Note that the path specified as the parameter of exists function is relative to the folder of that QDir, not the working directory. So QDir(“a/b”).exists(“a/b”) is actually checking if the folder/file “a/b/a/b” exists.
Comments are closed, but trackbacks and pingbacks are open.