解决方案 »

  1.   

    既然知道命名格式 为什么不用个 for循环
    for(int i = 1;i<100;i++)
    {
         .....
        str.Format("%d.bmp",i);
         .......
    }
      

  2.   

    system("dir /b /a-d /os c:\\*.* >d:\\allfiles.txt");
    //读文件d:\\allfiles.txt的内容即C:\\下所有文件的名字,按文件大小从小到大顺序
    system("dir /b /a-d /s /o-d c:\\*.* >d:\\allfilesinsub.txt");
    //读文件d:\\allfilesinsub.txt的内容即C:\\下所有文件的名字包含子目录,按文件时间从新到旧顺序
    system("dir /b /ad c:\\*.* >d:\\alldirs.txt");
    //读文件d:\\alldirs.txt的内容即C:\\下所有子目录的名字
    请记住,能用shell命令获取文件、文件夹信息或者操作文件、文件夹最好用shell命令获取或者操作,而不要用各种API获取或者操作,因为当遇到非法文件夹名或非法文件名或非法文件长度、非法文件日期、压缩文件、链接文件、稀疏文件……等各种意料之外的情况时,API会处理的不全面或陷入死循环,而shell命令不会。
      

  3.   


    按照上面人说的啊先乱序读入vector之类的容器
    然后自己写个排序函数
    就得到你的内容了或者看下#7的说明,反正我看不太懂
      

  4.   

    用set或map来存储,开发自定义的比较函数,这样存储进去,就是按照你的期望有序的了
      

  5.   

    //集合
    #include <vector>#define VEC_STRING std::vector<CString>VEC_STRING VecImageName;//图片文件夹的图片名称集合GetFloderVecImageName(szImageFloderPath,  VecImageName);//获取图片名称集合sort(VecImageName.begin(), VecImageName.end(), CmpImageName);/***********************************************************
    ** 功能描述: 获取文件夹下的图片名称集合
    ************************************************************/
    void CReadImageDataDlg::GetFloderVecImageName(CString szPath, VEC_STRING& VecImageName)
    {
    CFileFind ff; BOOL bFind = ff.FindFile(szPath + _T("\\*.*")); while(bFind)
    {
    bFind = ff.FindNextFile(); if (ff.IsDots() 
    || ff.IsSystem() 
    || ff.IsHidden()
    || ff.IsDirectory())
    {
    continue;
    }
    else
    {
    CString szFilePath = ff.GetFilePath(); CString szExt = HandlePath::GetFileExt(szFilePath);//文件后缀 //判断文件后缀
    if (_T("bmp") != szExt)
    {
    continue;
    } CString szFileName = ff.GetFileName(); //判断文件名称
    //if (szFileName.Left(4) != _T("IMG_"))
    //{
    // continue;
    //} //添加图片名称
    VecImageName.push_back(szFileName);
    }
    }
    }//用来做图片名称比较函数
    bool CmpImageName(CString &string1, CString &string2)

    CString szNum1 = string1.Mid(4, string1.GetLength() - 8);
    int nNum1 = _ttoi(szNum1); CString szNum2 = string2.Mid(4, string2.GetLength() - 8);
    int nNum2 = _ttoi(szNum2); if (nNum1 < nNum2)
    {
    return true; 
    }
    else 
    {
    return false; 
    }
    }