|
发表于 2020-4-22 10:30:01
|
显示全部楼层
//给你一个自定义的函数来得到指定文件是否存在
bool FileExist(LPCTSTR szFindPath)
{
int count = 0;
int i = 0;
WIN32_FIND_DATA fd;
HANDLE hFind;
if(strlen((char *)szFindPath) <= 0 )
return false;
char path[257];
char *pPath;
pPath = path;
count = strlen(szFindPath);
if(count <=0)
return false;
//从前向后得到路径字符串
for( i = 0; i<count; i++)
{
if(*(szFindPath+i) == '\\')
break;
*(pPath+i) = *(szFindPath+i);
}
*(pPath+i) = '\\';
*(pPath+i+1) = '\0';
hFind = FindFirstFile(szFindPath, &fd );
if ( hFind != INVALID_HANDLE_VALUE )
{
FindClose( hFind );
}
return hFind != INVALID_HANDLE_VALUE;
} |
|