The code is as follows
int _finder (LPCTSTR pstr)
{
CFileFind Finder;
CString Strwildcard (PSTR);
Strwildcard + = _t ("//*.*");
BOOL bworking = Finder. FindFile (Strwildcard);
int i = 0;
while (bworking)
{
bworking = Finder. FindNextFile () & Finder.isdots () & Finder. Isdirectory ();
Nonzero if the found file has the name "." or "...", which indicates that the found file is actually a directory. otherwise 0
/*
bworking = Finder. FindNextFile ();
if (!bworking)
break;
*/
If a file exists, execute the following
bworking = Finder. FindNextFile ();
if (finder. Isdots ())//if yes. Or.. Just continue.
{
bworking = Finder. FindNextFile ();
Continue;
}
General files and folders
printf ("%d%s/n", ++i, finder.) GetFileName ());
BOOL bisdir = Finder. Isdirectory ();
if (Bisdir)
{//is a folder
CString Repath = Finder. GetFilePath ();
_finder (Repath);
}
Else
{//is a file
Do parse
CString Repath = Finder. GetFilePath (); eg return c:/myhtml/myfile.txt
}
}//end while
Finder. Close ();
return 1;
}
There are the following points that may not be understood by people,
What is the use of isdots?
Isdots is to determine if the current file is. Or. files, each folder under Windows has these two files, ... Represents the parent directory,. Represents the current directory, desktop Windows is not visible, the following methods can be seen. , go to the command line and enter Dir to display all the directories under the current folder, and you will also find that. , the program must remove these two when running to prevent endless loop
You may encounter less reading a file, I made such a mistake in the beginning, I thought it was a bug in MS, it was my bug~
Your findnextifle must not be seated by number.
May be while (Finder.filenextfile ()) so written, you missed the first file, do not believe to try ~
And everyone wrote the traversal when the last file was found missing,
I guess that's what you wrote.
bworking = Finder.findnextfile ();
while (bworking)
{
bworking = Finder.findnextfile ();
Do something
......
}
This means that the last file is missing.
Missing the file that is logic problem ~ Good fix ~
Traversing the file in a fixed order, look at the reference body
Over the