June 12th, 1999, 09:06 AM
Hi, I am using this class 'CFileFind' to read in all files of a certain extension. Below is the code :
CFileFind oFinder;
CString oFilename;
/* Search for files */
if (oFinder.FindFile ("*.SAV") != FALSE)
{
/* Loop until no file is found */
while (oFinder.FindNextFile () == TRUE)
{
/* Get filename */
oFilename = oFinder.GetFileName ();
// Here i will use the filename to load the data
.
.
}
/* End the earch */
oFinder.Close ();
}
The problem with this is that i will always read in 1 file less, e.g 20 files found, only 19 read in. I suspected I need to get the file name immediately after the 'FileFind' function is successful but in the Microsoft Help documentation, the 'GetFileName' function can be only called when 'GetNextFile' function is called at least once.
Hope that you guys can help me. Thanks!!
CFileFind oFinder;
CString oFilename;
/* Search for files */
if (oFinder.FindFile ("*.SAV") != FALSE)
{
/* Loop until no file is found */
while (oFinder.FindNextFile () == TRUE)
{
/* Get filename */
oFilename = oFinder.GetFileName ();
// Here i will use the filename to load the data
.
.
}
/* End the earch */
oFinder.Close ();
}
The problem with this is that i will always read in 1 file less, e.g 20 files found, only 19 read in. I suspected I need to get the file name immediately after the 'FileFind' function is successful but in the Microsoft Help documentation, the 'GetFileName' function can be only called when 'GetNextFile' function is called at least once.
Hope that you guys can help me. Thanks!!