![]() |
#2
wube2012-04-19 13:23
CStringArray strarray;
void FindFiles(LPCTSTR path,CString FTitle,LPCTSTR Ext,HWND hDlg) { char szFilter[MAX_PATH]; _makepath( szFilter, NULL, path, "*", "*" ); // 开始搜寻目录下的档案---------------------------- CFileFind Finder; BOOL bWorking = Finder.FindFile( szFilter ); if ( bWorking == false ) return; printf("[PATH] %s\n", path ); // 印出目录名称 strarray.SetSize(B); while (bWorking) { bool StringCompare=false; bWorking = Finder.FindNextFile(); if ( Finder.IsDots() ) // 若为 . or .. 则不处理 continue; else { CString str=Finder.GetFileName(); CString Point =str.LockBuffer(); CString ch = Point.Mid(Point.ReverseFind('.')+1,str.GetLength()-Point.ReverseFind('.')); if (Point.Find('_')) { CString fTitle=Point.Mid(0,Point.ReverseFind('_')+1); fTitle.TrimLeft();fTitle.TrimRight(); if (((LPCTSTR)fTitle)==1) StringCompare=true; } if ((ch==Ext) && (StringCompare==true)) // Compared File in the Same Folder { CListBox *pCtrl_1 = (CListBox*)AfxGetMainWnd()->GetDlgItem(IDC_LIST1); pCtrl_1->AddString((LPCTSTR)str); TCHAR buffer[B]={0}; strcpy(buffer,path); strcat(buffer,(LPCTSTR)str); strarray.SetAt(FileCount, (LPCTSTR)buffer); FileCount++; } else // All File in the Same Folder { CListBox *pCtrl_2 = (CListBox*)AfxGetMainWnd()->GetDlgItem(IDC_LIST2); pCtrl_2->AddString((LPCTSTR)str); } } } } 取出指定文件夹内特定档案并列出至LISTBOX的~部分自己作修改就能复制一个文件夹里面的所有文件~ |
vc++,就是选中一个文件夹后复制里面所有文件到指定文件夹,我现在已经可以复制单个文件到一个目标文件夹里了~希望加上注释~新人~