I was making a simple program with WinAPI to check if a directory exists, this is the function code:
BOOL directoryExists( LPCSTR path ) {
DWORD pathAttributes = GetFileAttributes ( path );
return pathAttributes != INVALID_FILE_ATTRIBUTES
&& pathAttributes == FILE_ATTRIBUTE_DIRECTORY;
}
Then I test it with this line of code in my main:
std::cout << ( ( directoryExists( "C:\\Users\\Admin\\Desktop" ) ?
"Directory found" : "Directory not found" )
<< static_cast< char >( 0xA );
It looks like I get "Directory not found" no matter what absolute path I try to input. Anyway with relative paths it succeeds!
Where did I fail? :|
Thanks in advance!