BROWSEINFO bi;
char buffer[MAX_PATH];
ZeroMemory(buffer, MAX_PATH);
bi.hwndOwner = GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = (LPWSTR)buffer;
bi.lpszTitle = _T("请选择文件夹");
bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = 0;
bi.iImage = 0;
LPITEMIDLIST pList = NULL;
if ((pList = SHBrowseForFolder(&bi)) != NULL)
{
char path[MAX_PATH];
ZeroMemory(path, MAX_PATH);
SHGetPathFromIDList(pList, (LPWSTR)path);
m_strShowFileInfo.Format(_T("%s"), path);//保存路径
/* 查找的目标文件 */
CString strTarget;
/* 查找到的符合要求的文件的名字 */
CString strName;
strTarget = m_strShowFileInfo + _T("\\") + _T("*.xml");
CFileFind finder;
BOOL bWorking = FALSE ;
bWorking = finder.FindFile(strTarget);
if (bWorking)
{
finder.FindNextFile();
/* 或者目标文件的名字 */
strName = finder.GetFileName();
m_strShowFileInfo = m_strShowFileInfo + _T("\\") + strName;
UpdateData(FALSE);
}
}