#includeint main() { CString dirName = L"C:\\Users\\JohnDoe\\Documents\\Files\\"; CFileFind find; BOOL hasNextFile = find.FindFile(dirName + L"*.*"); int count = 0; while (hasNextFile) { hasNextFile = find.FindNextFile(); count++; } std::cout << "Total number of files in directory: " << count << std::endl; }
#includeThis example highlights how the `CFileItemList` class can also be used to keep track of individual files or directories. In this case, we add the directory path to the list and retrieve its size using `GetSize()`. This code also uses the MFC library.int main() { CString dirName = L"C:\\Users\\JohnDoe\\Documents\\Files\\"; CFileItemList list; list.AddItemListItem(dirName); std::cout << "Total number of items in list: " << list.GetSize() << std::endl; }