有一目录树机构如下:Series01 在它目录下有FileName01 FileName02 FileName03等文件名Series02 ------FileName01 FileName02 FileName03----Series03 ------FileName01 FileName02 FileName03----我想读取Series的目录名在lise ConTrol中的行显示出来
在另外一个list ConTrol中把FileName也显示出来不知道该怎样来实现,那位高手能给些建议;或者有些例子,感激不尽

解决方案 »

  1.   

    //test6dlg.h
    CStringArray m_strArrFilename;//test6dlg.cpp
    void CTest6Dlg::FindMyFile(CString path){    BOOL bFind, bFindSuffix; CFileFind tempFind, tempFind1; _chdir(path); bFind = tempFind.FindFile("*.*"); while(bFind) { bFind = tempFind.FindNextFile(); if(tempFind.IsDirectory()) { if (!tempFind.IsDots() ) { CString temppath; temppath = tempFind.GetFilePath(); FindMyFile(temppath);  } } } _chdir(path); bFindSuffix = tempFind1.FindFile("*.*"); while(bFindSuffix) { bFindSuffix = tempFind1.FindNextFile(); CString filepath, filename; if( !tempFind1.IsDirectory() && !tempFind1.IsDots()) { //得到目录下所有文件路径 filepath = tempFind1.GetFilePath();//文件名可用GetFileName替换GetFilePath() m_strArrFilename.Add(filepath); } } tempFind.Close(); tempFind1.Close();}调用
    void CTest6Dlg::OnButton1()
    {
    CString str;
    FindMyFile("c:\\Series01");
    for(int i=0; i<m_strArrFilename.GetSize(); i++)
    {
    str += m_strArrFilename[i];//m_strArrFilename[i]就是每个文件名
    str += "\r\n";
    }
    AfxMessageBox(str);
    }关于listcontrol的操作你可以看
    http://www.vchelp.net/wyy/tour/vc_road.asp
    4.8 List Ctrl
      

  2.   

    谢谢你的帮助不好意思,我是刚刚接触VC,所以有些看不懂,不知道能否做一个简单的例子吗
    [email protected]
      

  3.   

    http://www.codeproject.com/listctrl/filedroplistctrl.asp