怎样用mfc找到文件夹路径,并读取文件夹内所有

怎样用mfc找到文件夹路径,并读取文件夹内所有,第1张

这个是删除文件的用法,找到文件和删除文件都差不多。用CFileFinder可以遍历。 void DelFiles(CString& strDirPath, CString strFileName, BOOL bDelAll) { CFileFind FileFinder; strDirPath = strDirPath + _T("\\"); CString strFilePath

CFileFind find;

CString Path = lpszPath;

CString lpsz = Path +L"\\";

Path = Path +L"\\";

BOOL IsFind = findFindFile(Path);

while(IsFind )

{

IsFind=findFindNextFile();

//如果是""则不扫描

if(findIsDots())

continue;

//是目录,继续扫描此目录

else if(findIsDirectory())

{

CString strPath = lpszPath;

strPath = strPath + L"\\" + findGetFileName();

ScanDiskFile(strPath);

}

//文件

else

{

//获得文件的路径

m_strFile = findGetFileName();

CString extend = m_strFileRight(m_strFileGetLength() - m_strFileReverseFind('') - 1);//取得扩展名

if (extend == m_ext_one | extend == m_ext_two)//m_ext_now为你要查找的文件扩展名

{

m_strArrayAdd(lpsz + m_strFile);

}

}

}

findClose();

m_ext_one、m_ext_two用于指定需要搜索的文件后缀名

用EnumFontFamiliesEx函数就可以了,示例如下:

LOGFONT lf;

ZeroMemory(&lf,sizeof(LOGFONT));

lflfCharSet = DEFAULT_CHARSET;

_tcscpy(lflfFaceName,TEXT(""));

EnumFontFamiliesEx(pDC->GetSafeHdc(),&lf,(FONTENUMPROC)EnumFontFamiliesProc,(LPARAM)this,0);BOOL CALLBACK CFontCombo::EnumFontFamiliesProc(LPENUMLOGFONT lpelf,LPNEWTEXTMETRIC lpntm,DWORD nFontType,long lParam)

{

if(!(nFontType & RASTER_FONTTYPE))

{

// if (lpelf->elfLogFontlfCharSet == ANSI_CHARSET || lpelf->elfLogFontlfCharSet == GB2312_CHARSET)

{

CFontCombo pCombo = (CFontCombo )lParam;

//过滤以@开头的字体,过滤已经添加的字体。

if(lpelf->elfFullName[0] != TEXT('@') && pCombo->FindStringExact(0,(LPCTSTR)lpelf->elfFullName) == LB_ERR)

{

int index = ((CFontCombo )lParam)->AddString((LPCTSTR)lpelf->elfFullName);

LPLOGFONT lpLF = new LOGFONT;

CopyMemory(lpLF,lpelf,sizeof(LOGFONT));

((CFontCombo )lParam)->SetItemData(index,(DWORD)lpLF);

}

}

}

return TRUE;

}

这个满足你的要求s返回文件路径#defineDLG_FILTER"ALLFiles()|||"#defineDLG_EXT""CFileDialogdlg(TRUE,_T(DLG_EXT),NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT,_T(DLG_FILTER));if(dlgDoModal()==IDOK){POSITIONpos=dlgGetStartPosition();while(pos!=0){CStrings=dlgGetNextPathName(pos);}}下面代码,可以选择文件夹,会返回文件夹的路径需要自己查找每个文件charGetPath(HWNDhWnd,charpBuffer){BROWSEINFObf;LPITEMIDLISTlpitem;memset(&bf,0,sizeofBROWSEINFO);bfhwndOwner=hWnd;bflpsztitle="选择路径";bfulFlags=BIF_RETURNONLYFSDIRS;//属性你可自己选择lpitem=SHBrowseForFolder(&bf);if(lpitem==NULL)//如果没有选择路径则返回0return0;//如果选择了路径则复制路径,返回路径长度SHGetPathFromIDList(lpitem,pBuffer);returnpBuffer;}

快慢的物理量。 速体在单位时间内通过的路程。

以上就是关于怎样用mfc找到文件夹路径,并读取文件夹内所有全部的内容,包括:怎样用mfc找到文件夹路径,并读取文件夹内所有、怎样用mfc找出文件夹路径,并读取文件夹内所有图片、mfc如何获取系统字体文件路径等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9639749.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-30
下一篇2023-04-30

发表评论

登录后才能评论

评论列表(0条)

    保存