CreateFile检测(32位Windows),随后CloseHandle
dwDesiredAccess = 0;
dwShareMode = FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE;
dwCreationDisposition = OPEN_EXISTING;OpenFile检测(16位Windows)
uStyle = OF_EXIST;
dwDesiredAccess = 0;
dwShareMode = FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE;
dwCreationDisposition = OPEN_EXISTING;OpenFile检测(16位Windows)
uStyle = OF_EXIST;
CFindFile *fl;
if(!fl->FindFile())
文件不存在;
else
文件存在;
..
CString szFindPath=m_szFileName;
int nSlash = szFindPath.ReverseFind('\\');
if( nSlash == szFindPath.GetLength()-1)
szFindPath = szFindPath.Left(nSlash);
HANDLE hFind = FindFirstFile( szFindPath, &fd );
if ( hFind != INVALID_HANDLE_VALUE )
FindClose( hFind );
return hFind != INVALID_HANDLE_VALUE;
但CreateFile确实是绕弯子,还是FileExists好。
但是有一点麻烦,
只能说是一种思路。