どこが間違っているのかわかりません。この現在のコードは、closefile に直接スキップします。ファイルを処理していません。明らかな何かが欠けているだけかもしれません。長い一日でした。
私の機能は、特定のファイルのハードディスク (c:) を検索するためのものです。EG example.txt. ここの &strFilePath は、FindFirstFile 宣言で使用されます。
どんな助けでも歓迎されます。
ありがとう。
String Copy::SearchDrive( const String& strFile, const String& strFilePath, const bool& bRecursive, const bool& bStopWhenFound ) const
{
HANDLE hFile;
WIN32_FIND_DATA file;
hFile = FindFirstFile("C:\\", &file);
String strFoundFilePath = "";
if ( hFile )
{
while ( FindNextFile( hFile, &file))
{
String strTheNameOfTheFile = file.cFileName;
// It could be a directory we are looking at
// if so look into that dir
if ( file.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY
&& bRecursive )
{
String strNewFilePath = strFilePath + "\\";
strNewFilePath += strTheNameOfTheFile;
SearchDrive( strFile, strNewFilePath, bRecursive, bStopWhenFound );
}
else
{
if ( strTheNameOfTheFile == strFile )
{
strFoundFilePath = strFilePath;
strFoundFilePath += "\\";
strFoundFilePath += strFile;
/// TODO
// ADD TO COLLECTION TYPE
if ( bStopWhenFound )
{
break;
}
}
}
}
CloseHandle( hFile );
}
return strFoundFilePath;
}