16,548
社区成员




TCHAR strFileName[MAX_PATH] = {0};
TCHAR szFilter[] = "*.*";
CFileDialog dlg(FALSE, NULL, strFileName, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT, szFilter, NULL);
if ( dlg.DoModal() == IDOK )
{
CString strpath;
int nPos;
/* //单选文件获取文件名 调用
strpath = dlg.GetFileName();
AfxMessageBox(strpath); */
//多选文件获取文件名
POSITION pos = dlg.GetStartPosition();
while ( pos != NULL )
{
strpath = dlg.GetNextPathName(pos);
nPos = strpath.ReverseFind('\\');
CString cs = strpath.Right(strpath.GetLength() -nPos - 1);
AfxMessageBox(cs);
}
}
size_t l = _tcslen( filename );
while( '\\' != filename[ l ] )
{
l--;
}
AfxMessageBox( filename + l + 1 );