How to check whether given directory is existing or not?
How to check whether given directory is existing or not?
Try QDir::exists()![]()
Thanks for your reply man.
Ya man... i know abt this method of QDir. But first of all we have to create an object of QDir with some argument.
Now i have a string say c:\Shailesh and i want to check whether this directory exists or not???
Have you tried:Originally Posted by shailesh
Qt Code:
To copy to clipboard, switch view to plain text mode
Thanks very much man... Its working...
Or, rather:Originally Posted by Dark_Tower
Qt Code:
To copy to clipboard, switch view to plain text mode![]()
Save yourself some pain. Learn C++ before learning Qt.
Sorry Chicken Blood Machine for my ignorance, but i've never seen accessing a directory with double dashed bar. Can you explain me please if exists any difference between accessing with one dashed bar or two?Originally Posted by Chicken Blood Machine
The backslash '\' is a special escape charater, used to mark no-printable characters like tab ('\t'), newline ('\n'), etc . Therefore you can't use '\' on its own. You must use '\\'.
Save yourself some pain. Learn C++ before learning Qt.
Actually, it is better to access the directories like this: "C:/MyDir/MySubdir" (using slashes instead of backslashes) with QT, especially if you are working on a code that is intended to work on some platforms other than win.
The difference between "\\" and "\" is that "\" symbol in C++ string constants marks the beginning of the escape sequence (like "\n" for newline). Therefore, if you wish to have a "\" symbol in your string you have to use a "\\" escape sequence.
Trust me "C:/MyDir/MySubdir" will work on no other platform than Windows!Originally Posted by Lemming
Ideally, you will avoid absolute paths altogether and yes, it is better to use the forward slash for Qt code.
Save yourself some pain. Learn C++ before learning Qt.
Thanks both, now I've got it clear!
Bookmarks