容器

/*获取文件夹路径下所有的xml文件并放入容器中*/
 1     /******************************************/
 2     /*获取文件夹路径下所有的xml文件并放入容器中*/
 3      
 4     CString  csDirPath;
 5     CFileDialog dlg(TRUE);///TRUE为OPEN对话框,FALSE为SAVE AS对话框  
 6     CString m_csFileName;
 7     if (dlg.DoModal() == IDOK)
 8     {
 9         m_csFileName = dlg.GetPathName();
10     }
11     else{
12         m_csFileName.Empty();
13         return;
14         }
15     int iEndPos = 0;
16     iEndPos = m_csFileName.ReverseFind('\\');
17     csDirPath = m_csFileName.Left(iEndPos);
18 
19     csDirPath += "\\*.xml";
20     HANDLE file;
21     WIN32_FIND_DATA fileData;
22     //char line[1024];  
23     //char fn[1000];  
24     /*vector<CString> m_FileList;*/
25     //mbstowcs(fn,csDirPath.GetBuffer(),999);  
26     m_FileList.clear();
27     file = FindFirstFile(csDirPath.GetBuffer(), &fileData);
28      
29     CString DirpathOne = m_csFileName.Left(iEndPos)+"\\"+ fileData.cFileName;
30     m_FileList.push_back(DirpathOne);
31     BOOL bState = false;
32     bState = FindNextFile(file, &fileData);
33     while (bState){
34         //wcstombs(line,(const char*)fileData.cFileName,259);  
35         CString Dirpath = m_csFileName.Left(iEndPos)+"\\"+ fileData.cFileName;
36         m_FileList.push_back(Dirpath);
37         bState = FindNextFile(file, &fileData);
38     }
39 
40     UpdateData(TRUE);
41     char DirTemp[300];
42     for (int i=0; i < m_FileList.capacity();i++)
43     {
44         CstringToch(m_FileList.at(i), DirTemp);
45         if (!MUltiModifyXMl(DirTemp))
46         {
47             MessageBox(_T("modify uncompeleted in " + m_FileList.at(i)));
48         }
49         
50         
51     }
52     MessageBox(_T("MUltiModifyXMl ends"));

 


 

posted @ 2017-01-06 11:49  xifengIB  阅读(124)  评论(0编辑  收藏  举报