TCAHR szFile[] = _T("c:\\a.exe");
if (_access(szFile, 00) == 0)
{
AfxMessageBox("文件存在");
}
函数定义如下:
int _access(
const char *path,
int mode
);
mode value Checks file for
00 Existence only
02 Write-only
04 Read-only
06 Read and write
咋这么懒涅,MSDN的东东,我给你贴上了!
CFileFind finder;
static const TCHAR szFileToFind[] = _T("C:\\WINDOWS\\SYSTEM.INI");
BOOL bResult = finder.FindFile(szFileToFind);
if (bResult)
{
finder.FindNextFile();
cout << "Root of " << szFileToFind;
cout << " is " << (LPCTSTR) finder.GetRoot();
cout << endl;
cout << "Title of " << szFileToFind;
cout << " is " << (LPCTSTR) finder.GetFileTitle();
cout << endl;
cout << "Path of " << szFileToFind;
cout << " is " << (LPCTSTR) finder.GetFilePath();
cout << endl;
cout << "URL of " << szFileToFind;
cout << " is " << (LPCTSTR) finder.GetFileURL();
cout << endl;
cout << "Name of " << szFileToFind;
cout << " is " << (LPCTSTR) finder.GetFileName();
cout << endl;
finder.Close();
}
else
cout << "You have no " << szFileToFind << " file." << endl;