[vc][mfc]
ファイル単体の存在チェック
CFileFind find;
CString filePath = _T("C:\\foo.bar");
if( find.FindFile( filePath ) ){
// ファイルが存在
}
フォルダ内ファイルの存在チェック
以下の例ではでファイル名の条件を指定。
CFileFind find;
CString dirPath = _T("C:\\foo\\bar");
dirPath += _T("*.txt"); // ファイルの条件
if( find.FindFile( dirPath ) ){
// while( find.FindNextFile() ) // ※間違い※これだと処理出来るファイルが実際の数より1つ少ない
bool flag;
do{
flag = find.FindNextFile();
// *.txtファイルが存在したときの処理
}while( flag ); // これなら対象ファイル全てが処理出来る
}