Hi all! Is there a Windows function that check me if it's a directory? If it doesn't exist, is there a mode?
Printable View
Hi all! Is there a Windows function that check me if it's a directory? If it doesn't exist, is there a mode?
Or even more succintly
PathIsDirectory Function (Windows)
thank you both!
For other user that they will have same problem, this is the solution:
Code:...
isDirectory = GetFileAttributes( struttura.cFileName );
if ( isDirectory == FILE_ATTRIBUTE_DIRECTORY )
cout << "it's a dir" << endl;
else
cout << "it isn't a dir" << endl;
....
It's still wrong -> File Attribute Constants (Windows)
The result is a bit-mask, so your example would fail for a hidden directory.
You need to do
Code:isDirectory = GetFileAttributes( struttura.cFileName );
if ( ( isDirectory & FILE_ATTRIBUTE_DIRECTORY ) == FILE_ATTRIBUTE_DIRECTORY )