POSITION pos;
  pos = dlgOpen.GetStartPosition();
  while(pos!=NULL)
  {
    path = dlgOpen.GetNextPathName(pos);
    nItem = m_listFile.InsertItem(i,"");
    m_listFile.SetItemText(nItem, 2,path);
    i++;
  }这里不能用dlgOpen.GetFileName()来获得文件名,那想获得,怎么办???

解决方案 »

  1.   

    CFileDialog Dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT);
    if(Dlg.DoModal()==IDOK)
    {
    POSITION pos = Dlg.GetStartPosition();
    while(pos)
    {
    CString szFileName = Dlg.GetNextPathName(pos);
    AfxMessageBox(szFileName);
    }
    }
      

  2.   

    你这样szFileName是获得比如c:\windows\explorer.exe
    我想要的是单就文件名,也就是就explorer.exe
      

  3.   

    那对应把路径去掉就行了
    CFileDialog Dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT);
    CString szFileName,szFilePath;
    if(Dlg.DoModal()==IDOK)
    {
    POSITION pos = Dlg.GetStartPosition();
    szFilePath=Dlg.GetPathName();
    int indxe=szFilePath.GetLength();
    while(pos)
    {
    szFileName = Dlg.GetNextPathName(pos);AfxMessageBox(szFileName.Right(szFileName.GetLength()-szFilePath.GetLength()-1));//去路径}
    }