# DEFINE _ afxdll
# Include <afxwin. h>
# Include <iostream>
# Include <vector>
# Include <string>
Using namespace STD;
Int _ finder (lpctstr pstr)
{
Cfilefind finder;
Vector <cstring> SVEC;
Cstring strwildcard (pstr );
Strwildcard + = _ T ("\\*.*");
Bool bworking = finder. findfile (strwildcard );
Int I = 0;
While (bworking) // if there are other files, execute the following
{
Bworking = finder. findnextfile ();
If (finder. isdots () // If yes, continue.
{
Bworking = finder. findnextfile ();
Continue;
}
// General files and folders
Bool bisdir = finder. isdirectory ();
If (bisdir)
{// Folder
Cstring repath = finder. getfilepath ();
Wchar_t * SZ = (wchar_t *) repath. getbuffer (repath. getlength ());
Wcout <SZ <Endl;
}
Else
{// File
// Output file path
Cstring repath = finder. getfilepath (); // eg return c: \ myhtml \ myfile.txt
Wchar_t * SZ = (wchar_t *) repath. getbuffer (repath. getlength ());
Wcout <SZ <Endl;
// Output file name
Cstring filename = finder. getfilename ();
Wchar_t * fn = (wchar_t *) filename. getbuffer (filename. getlength ());
Wcout <FN <Endl;
}
} // End while
Finder. Close ();
Return 1;
}
# Include <string>
Int main ()
{
Cstring filepath ("d :\\ train \\");
_ Finder (filepath );
Return 0;
}