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;

解决方案 »

  1.   

    ...
    CFindFile *fl;
    if(!fl->FindFile())
    文件不存在;
    else
    文件存在;
    ..
      

  2.   

    FindFile和CreateFile都是绕弯子的做法,同意xzgyb的做法,用FileExists函数,简单易用。
      

  3.   

    WIN32_FIND_DATA fd;
    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;
      

  4.   

    CFindFile怎么是绕弯子呢???
      

  5.   

    就用FileExists嘛,就和CFile::Open很类似,但不用打开文件,就这么简单,为什么不用呢?
      

  6.   

    hackerning,Flysnow,不好意思,MFC类库我不懂,我上面说错了:)
    但CreateFile确实是绕弯子,还是FileExists好。
      

  7.   

    也可以用Shell API,
    但是有一点麻烦,
    只能说是一种思路。