地址:蚊子132 给大家写一段最简单的CFileFind 源码
文件查找在一般的项目开发中是经常用到的,蚊子132 今天就给大家写一段最简单的CFileFind 源码:
Example
CFileFind finder;static const TCHAR szFileToFind[] = _T("C:\\WINDOWS\\SYSTEM.INI");BOOL bResult = finder.FindFile(szFileToFind);if (bResult){ finder.FindNextFile(); cout << "Root of " << szFileToFind; cout << " is " << (LPCTSTR) finder.GetRoot(); cout << endl; cout << "Title of " << szFileToFind; cout << " is " << (LPCTSTR) finder.GetFileTitle(); cout << endl; cout << "Path of " << szFileToFind; cout << " is " << (LPCTSTR) finder.GetFilePath(); cout << endl; cout << "URL of " << szFileToFind; cout << " is " << (LPCTSTR) finder.GetFileURL(); cout << endl; cout << "Name of " << szFileToFind; cout << " is " << (LPCTSTR) finder.GetFileName(); cout << endl; finder.Close();}else cout << "You have no " << szFileToFind << " file." << endl;
Example Output
Assumes that the file C:\WINDOWS\SYSTEM.INI exists:
Root of C:\WINDOWS\SYSTEM.INI is C:\WINDOWSTitle of C:\WINDOWS\SYSTEM.INI is SYSTEMPath of C:\WINDOWS\SYSTEM.INI is C:\WINDOWS\SYSTEM.INIURL of C:\WINDOWS\SYSTEM.INI is file://C:\WINDOWS\SYSTEM.ININame of C:\WINDOWS\SYSTEM.INI is SYSTEM.INI