我现在要写一个在指定的文件夹里面,统计且列出所有文件(不包括子文件),我想引用mfc中的
CFile类,和CFileFind类, 要怎样引用? 或有另外的sdk函数?

解决方案 »

  1.   

    #include <afxwin.h>
    #include <afxext.h>
    改为多线程调试.
      

  2.   

    API (查找某类文件):
    BOOL ShowFileList(CString strPath,CString strFileExt) 
    {        WIN32_FIND_DATA FindFileData;
            HANDLE hFind;
            hFind = FindFirstFile(strPath+strFileExt, &FindFileData);  
            
            if (hFind == INVALID_HANDLE_VALUE) {
                    TRACE ("Invalid File Handle. Get Last Error reports %d\n", GetLastError ());
    return FALSE;
            } else {
                    TRACE ("The first file found is %s\n", FindFileData.cFileName);
                    while(FindNextFile(hFind,&FindFileData))
                    {
                            TRACE ("The next file found is %s\n", FindFileData.cFileName);
                    }
            }
            FindClose(hFind);
            return TRUE;
    }
    //调用示例: ShowFileList(_T("C:\\seu\\"), _T("*.*"));
      

  3.   

    加上相应的头文件就可以了,一般afx.h