How can I get the first file of FindFile?
-
If I search a file with: CFileFind fFind; find.FindFile("*.bmp"); find.GetFilePath(); the programm crashes. MSDN says that I must call FindNextFile() at least once, but then I get the path of the second file and not of the first. So, how can I get the path of the first file?:confused:
-
If I search a file with: CFileFind fFind; find.FindFile("*.bmp"); find.GetFilePath(); the programm crashes. MSDN says that I must call FindNextFile() at least once, but then I get the path of the second file and not of the first. So, how can I get the path of the first file?:confused:
There seems to be a bug in the MFC class of CFileFind. Use instead FindNextFile() of the Win32 Platform SDK.
-
If I search a file with: CFileFind fFind; find.FindFile("*.bmp"); find.GetFilePath(); the programm crashes. MSDN says that I must call FindNextFile() at least once, but then I get the path of the second file and not of the first. So, how can I get the path of the first file?:confused:
No, there is no bug. You have to call FindNextFile at least once just like the documentation states. Basically this is what you do. CFileFind fFind; BOOL bFound = fFind.FindFile( "*.bmp" ); while ( bFound ) { bFound = fFind.FindNextFile(); // Do what you want with fFind, it is pointing to the first found file. } Hope that helps Wayne