如题目所示,先谢谢了

解决方案 »

  1.   

    判断一个文件是否存在
    CFileFind find;
    if (!find.FindFile("Yourfile.exe"))
      // 不存在
    find.Close();
      

  2.   

    int CDeleteWrongInfoDlg::IsDirectoryOrFile(CString strFileName)
    {
    strFileName.TrimLeft();
    strFileName.TrimRight();

    WIN32_FIND_DATA fd;
    HANDLE hFind = ::FindFirstFile(strFileName,&fd);
    ::FindClose(hFind); //不存在同名的文件或文件夹
    if (hFind == INVALID_HANDLE_VALUE)
    {
    return 0 ;
    }
    //判断是否为目录
    else if (fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
    {
    return 2 ;
    }
    else
    {
    return 1;
    }
    }
      

  3.   

    PathFileExists Function--------------------------------------------------------------------------------Determines whether a path to a file system object such as a file or directory is valid. SyntaxBOOL PathFileExists(          LPCTSTR pszPath
    );
      

  4.   

    最简单的方法是用ifstream打开该文件,如果打开成功,说明存在,否则不存在^_^
      

  5.   

    这才是最简单的方法
    PathFileExists(fileName);
    返回TRUE表示存在,FALSE表示不存在