<分区>
我正在用 WinAPI 编写一个简单的程序来检查目录是否存在,这是功能代码:
BOOL directoryExists( LPCSTR path ) {
DWORD pathAttributes = GetFileAttributes ( path );
return pathAttributes != INVALID_FILE_ATTRIBUTES
&& pathAttributes == FILE_ATTRIBUTE_DIRECTORY;
}
然后我在我的 main 中用这行代码测试它:
std::cout << ( ( directoryExists( "C:\\Users\\Admin\\Desktop" ) ?
"Directory found" : "Directory not found" )
<< static_cast< char >( 0xA );
看起来无论我尝试输入什么绝对路径,我都会得到“找不到目录”。不管怎样,相对路径都会成功!
我哪里失败了? :|
提前致谢!