#include
#include
#include
using namespace std;
int main(int argc,char *argv[])
{
string ifile("c:\\c.txt"),tmp;
ifstream ifs(ifile.c_str());
if(!ifs)
{
cout<<"不存在"<}
else cout<<"存在"<return 0;
}
判断C盘下C.txt是否存在
bool FileExist(char* strPrePath, const char* strFileName)
{
CFileFind cFindfile;
char strPath[2*256];
sprintf(strPath, "%s%s%s", strPrePath, "\\", strFileName);
return cFindfile.FindFile(strPath);
}
// strPrePath是文件所在路径不包括文件名 strFileName是文件名
用FindFile函数