加载文件夹里面的文件

 

CString strIni; //这个可以赋予初值,也可以设置为空 CString strPath; BROWSEINFO bi; char name[MAX_PATH]; ZeroMemory(&bi,sizeof(BROWSEINFO)); bi.hwndOwner = GetSafeHwnd(); bi.pidlRoot = NULL; // set root at Desktop bi.pszDisplayName = (LPWSTR)name; bi.lpszTitle=L"Select folder"; bi.ulFlags=BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS ; bi.lpfn = NULL; bi.lParam = (LPARAM)strIni.GetBuffer(strIni.GetLength());//0; LPITEMIDLIST pIdl; if((pIdl = SHBrowseForFolder(&bi)) != NULL) { TCHAR path[MAX_PATH]; SHGetPathFromIDList(pIdl,path); strPath = path; MessageBox(strPath); } CFileFind find; CString file; strPath = strPath + L"//*.*"; BOOL isfind=find.FindFile(strPath.GetBuffer()); while (isfind) { isfind=find.FindNextFile(); if (find.IsDots()) { continue; } file=find.GetFilePath(); MessageBox(file); } 

你可能感兴趣的:(加载文件夹里面的文件)