CFile myFile("example.txt", CFile::modeCreate | CFile::modeWrite); CString fileName = myFile.GetFileName();
CFile myFile("example.txt", CFile::modeRead); CString fileName = myFile.GetFileName(); std::cout << "The file name is: " << fileName << std::endl;In this example, we create a CFile object called "myFile" with the file name "example.txt" in read-only mode. We then use the GetFileName function to retrieve the file name as a CString object, which we print to the console using std::cout. The CFile class and its member functions are part of the MFC (Microsoft Foundation Class) library in C++.