CFileFind kk; if (kk.FindFile("c:\\kk.txt")) MessageBox("文件找到。"); else MessageBox("文件没找到。");
PathFileExists Determines whether a path to a file system object such as a file or directory is valid. BOOL PathFileExists( LPCTSTR pszPath );Parameters pszPath Full path of the object to verify. Return Values Returns TRUE if the file exists, or FALSE otherwise. Call GetLastError for extended error information.
CFileFind find;
bool IsFinded = find.FindFile("C:\\Test.bmp");
if(IsFinded)
{
//存在
}
else
{
//不存在
}
CFileFind kk;
if (kk.FindFile("c:\\kk.txt"))
MessageBox("文件找到。");
else
MessageBox("文件没找到。");
Determines whether a path to a file system object such as a file or directory is valid. BOOL PathFileExists(
LPCTSTR pszPath
);Parameters
pszPath
Full path of the object to verify.
Return Values
Returns TRUE if the file exists, or FALSE otherwise. Call GetLastError for extended error information.
使用函数 BOOL PathFileExists(LPCTSTR pszPath);
记得#include <Shlwapi.h>,链接Shlwapi.lib2.
使用函数_access,记得#include <io.h>
例子: bool bExist = (_access("c:\\test.txt", 0) != -1);