用mfc已经打开好一群图像,和已得到这群图像的个个路径,如何将他们保存到另外一个文件里。就是在增加一个按钮给他添加程序,是这个文件夹里的图像都存到另一个文件夹里。下面是打开文件夹和获取路径的代码void CHelloDlg::OnButton1() 
{
 BROWSEINFO   bi;  
 char   pszBuffer[MAX_PATH];  
 LPITEMIDLIST   pidl;  
 bi.hwndOwner=GetSafeHwnd();  
 bi.pidlRoot=NULL;  
 bi.pszDisplayName=pszBuffer;  
 bi.lpszTitle=_T("Help");  
 bi.ulFlags   =   BIF_RETURNFSANCESTORS   |   BIF_RETURNONLYFSDIRS;  
 bi.lpfn=NULL;  
 bi.lParam=0;  
 if((pidl=::SHBrowseForFolder(&bi))!=NULL)  
 {  
  if(::SHGetPathFromIDList(pidl,pszBuffer)) //此即为文件的路径
  {
   CFileDialog* filedialog;
   filedialog=new CFileDialog(true);
   CFileFind finder; //声明一个CFileFind变量
   CString strWildcard(pszBuffer); //将传入的参数赋于变量 strWildcard
   strWildcard += "\\*.jpg"; //构造成一个合格的查询字符串,类似于 c:\\aa\\*.*
   BOOL bWorking;
   bWorking = finder.FindFile(strWildcard); //开始查找
   while (bWorking)
   {
    bWorking = finder.FindNextFile(); //如果文件存在,继续查找下一个符合条件的文件
    //跳过"."和".."
    if (finder.IsDots())
     continue;
    //输出文件名
    CString strName = finder.GetFilePath();
    MessageBox(strName);//strname就是每个文件的路径,只要将他作为参数传给图像处理函数就行了
   }
   
   
  } 
 } 
}

解决方案 »

  1.   


    厄......
    你是想说你不会用CopyFile
      

  2.   

    差不多吧 挺难的 只要吧strname这个路径的图片保存到一个文件夹理就行了 对于高手来说应该很简单
      

  3.   

    // FindFirstFile, FindNextFile, CopyFile
      

  4.   

      while (bWorking)
      {
      bWorking = finder.FindNextFile(); //如果文件存在,继续查找下一个符合条件的文件
      //跳过"."和".."
      if (finder.IsDots())
      continue;
      //输出文件名
      CString strName = finder.GetFilePath();
      CString strNewPath;   //定义你的新路径。
      CopyFile(strName,strNewPath,FALSE);
      }
      

  5.   

    这样吧,在CHelloDlg  class中定义一个CString 的数组 strNameShuzu[](多大自己根据图片多少定个大概就行)以及一个 int N 然后将void CHelloDlg::OnButton1()   里后面的代码改成:
     int i = 0;
     while (bWorking)
      {
      bWorking = finder.FindNextFile(); //如果文件存在,继续查找下一个符合条件的文件
      //跳过"."和".."
      if (finder.IsDots())
      continue;
      //输出文件名
      CString strNameShuzu[i] = finder.GetFilePath();
      i++;
      }
      N = i;
    然后是写void CHelloDlg::OnButton2()  
           {
                CString newpath = "新的路径字符串";
                  CString newpicpath;
                for(int i = 0;i < N;++i)
                {
                    stringstream s; //这个是个字符串流,有可能拼写有点错误,可以msdn下
                    s<<i;
                    newpicpath = newpath + s;
                    CopyFile(strName,newpicpath,FALSE);//这个函数借用楼上的了哈。 
                     
                }
               
           } 
    ok ,it's done
    要给我分咯^_^