- //读取文件,将处理结果输出
- void ReadFiles(CString strAP, string _outPath)
- {
- ifstream read;
- read.open(strAP);
- ofstream write;
- write.open(_outPath.c_str(), ios::out | ios::app);
- if (write.fail() | read.fail())
- {
- cout << "ERROR!" << endl;
- }
- string line;
- while(!read.eof())
- {
- getline(read, line);
- if (line.size() == 0 || line =="\n")
- {
- continue;
- }
- write << line << endl;
- }
- read.close();
- write.close();
- }
- //循环读取每个文件
- void GetAllFiles(CString _strPath, string _outPath)
- {
- CString strAP;
- CFileFind finder;
- BOOL bworking=finder.FindFile(_strPath+"//*.*");
- int i = 0;
- while(bworking)
- {
- bworking=finder.FindNextFile();
- strAP=finder.GetFilePath();
- cout << "\r" << i++ << " " << strAP;
- if(finder.IsDots())
- {
- continue;
- }
- if(finder.IsDirectory())
- {
- GetAllFiles(strAP, _outPath);
- }
- ReadFiles(strAP, _outPath);
- }
- cout << endl;
- finder.Close();
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- //遍历的文件夹
- GetAllFiles("E:\\课题\\语料库\\863样本集Seg\\U", "U.txt");
- return 0;
- }