方法一:
if(::GetFileAttributes(sExeFile)==-1)
{
MessageBox(_T("文件不存在,请确认!"));
}
else
{
MessageBox(_T("文件已找到!"));
}
方法二:
CString sExeFile;
GetDlgItemText(IDC_EDIT_FILEFULLPATH, sExeFile);
if(::PathFileExists(sExeFile) != 1)
{
MessageBox(_T("文件不存在,请确认!"));
return;
}
文件类型是否匹配:
// Test path name 1.
BOOL retval = PathMatchSpec(sExeFile,_T("*.exe"));
if(retval == FALSE)
{
MessageBox(_T("请选择EXE文件"));
return;
}