FindNextFile( ) not working in 2nd iteration
-
HI, Suppose I have following files FileA.txt, FileB.txt, FileC.txt, FileD.txt, FileE.txt in the Directory C:\\Files\\ I want to create new files like FileA-FileB.txt merging the text of both files. Then FileA-FileC.txt then another FileA-FileD.txt, then FileA-FileE.txt I have created the above all the first file and its combination with other files but the problem is in remaing Means create the combinations of one file with all other. After first one create FileB-FileC, then FileB-FileD , then FileB-FileE . after that skip second one and create the combination of 3rd and forth file. so on When I ends up with first file combiantoin with other then I do BOOL find = finder.FindFile("C:\\Files\\FileA.txt"); BOOL get = finder.FindNextFile(); // to get the second file again , to make its combinations but here get give false; Why not it finds again the next file to the fileA. and return true. Thanks Regards.
-
HI, Suppose I have following files FileA.txt, FileB.txt, FileC.txt, FileD.txt, FileE.txt in the Directory C:\\Files\\ I want to create new files like FileA-FileB.txt merging the text of both files. Then FileA-FileC.txt then another FileA-FileD.txt, then FileA-FileE.txt I have created the above all the first file and its combination with other files but the problem is in remaing Means create the combinations of one file with all other. After first one create FileB-FileC, then FileB-FileD , then FileB-FileE . after that skip second one and create the combination of 3rd and forth file. so on When I ends up with first file combiantoin with other then I do BOOL find = finder.FindFile("C:\\Files\\FileA.txt"); BOOL get = finder.FindNextFile(); // to get the second file again , to make its combinations but here get give false; Why not it finds again the next file to the fileA. and return true. Thanks Regards.
-
HI, Suppose I have following files FileA.txt, FileB.txt, FileC.txt, FileD.txt, FileE.txt in the Directory C:\\Files\\ I want to create new files like FileA-FileB.txt merging the text of both files. Then FileA-FileC.txt then another FileA-FileD.txt, then FileA-FileE.txt I have created the above all the first file and its combination with other files but the problem is in remaing Means create the combinations of one file with all other. After first one create FileB-FileC, then FileB-FileD , then FileB-FileE . after that skip second one and create the combination of 3rd and forth file. so on When I ends up with first file combiantoin with other then I do BOOL find = finder.FindFile("C:\\Files\\FileA.txt"); BOOL get = finder.FindNextFile(); // to get the second file again , to make its combinations but here get give false; Why not it finds again the next file to the fileA. and return true. Thanks Regards.
FindNextFile()
finds the next file that matches the pattern given in the call toFindFile()
. Since you've only given one file name toFindFile()
,FindNextFile()
will always return false. To get all the text files, specify "C:\\Files\\*.txt" in the call toFindFile()
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
FindNextFile()
finds the next file that matches the pattern given in the call toFindFile()
. Since you've only given one file name toFindFile()
,FindNextFile()
will always return false. To get all the text files, specify "C:\\Files\\*.txt" in the call toFindFile()
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
In the 2nd iteration of upper loop , will not it again retuen the first file with *.text that will again be FileA, I want to get the 2nd file in 2nd iteration that is FileB , and 3rd file in 3rd iteration. In the inner loop its iterating to all file once then again come to outer loop Regards.
-
In the 2nd iteration of upper loop , will not it again retuen the first file with *.text that will again be FileA, I want to get the 2nd file in 2nd iteration that is FileB , and 3rd file in 3rd iteration. In the inner loop its iterating to all file once then again come to outer loop Regards.
No, if you call CFileFind::FindFile ("*.txt"), then it will give you the next file at each itteration of CFileFind::FindNextFile (). There are two remarks to be made: 1. You MUST call FindNextFile at least once before you can use the outcome of CFileFind. You cannot use the filename immediately after the call to FindFile. So what you do is: bLoop = Finder.FindFile ("*.txt", 0) while (bLoop) { bLoop = Finder.FindNextFile (); now you can use Finder.GetPath () or whatever } 2. There is no telling on the order in which you will receive the filenames. They will come in the order in which they happen to have been registered in the directory. If you need to handle the files in any particular order (e.g. alphabetically or based on age or whatever), you will need to first get all the filenames in a linked list or something like that, then sort them to the desired order and then use the files Regards