您的位置:首页 > 其它

MFC打开文件对话框,选择多个文件

2011-09-05 14:06 288 查看
size_t index;

CString cstrsucstring;

CFileDialog filedlg(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT |OFN_ALLOWMULTISELECT,_T("Source  Files(*.cpp;*.c;*.cc;*.cxx)|*.cpp;*.c;*.cc;*.cxx|Head Files(*.h;*.hpp;*.hxx)|*.h;*.hpp;*.hxx||"));

TCHAR *pBuffer = new TCHAR[MAX_PATH * 20];//最多允许同时打开20个文件

filedlg.m_ofn.lpstrFile = pBuffer;

filedlg.m_ofn.nMaxFile = MAX_PATH * 20;

filedlg.m_ofn.lpstrFile[0] = '\0';

if (filedlg.DoModal() == IDOK)

{

CString cstrfilepath = _T("");

POSITION pos = filedlg.GetStartPosition();

while (pos != NULL)

{

cstrfilepath = filedlg.GetNextPathName(pos);//取得文件路径

  }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: