Call this member function to retrieve the full path of a specified file. For example, when you call GetFilePath to generate a message to the user about the file c:\windows\write\myfile.wri, the file path, c:\windows\write\myfile.wri, is returned.上面是MSDN上的解释,但没有给出具体用法!哪位大虾能举个例子?谢谢了!

解决方案 »

  1.   

    try
       {
          // try to open the file
          CFile sysFile(_T("C:\\WINDOWS\\SYSTEM.INI"), CFile::modeRead);      // print out path name and title information
          _tprintf(_T("Path is : \"%s\"\n"), (LPCTSTR) sysFile.GetFilePath());
          _tprintf(_T("Name is : \"%s\"\n"), (LPCTSTR) sysFile.GetFileName());
          _tprintf(_T("Title is: \"%s\"\n"), (LPCTSTR) sysFile.GetFileTitle());      // close the file handle
          sysFile.Close();
       }
       catch (CFileException* pEx)
       {
          // if an error occurs, just make a message box
          pEx->ReportError();
          pEx->Delete();
       }