处理文件夹.txt

来自「解析email的源代码。 mine协议 解码译码」· 文本 代码 · 共 44 行

TXT
44
字号
vector<string> GetAllNewMail(string mailDir)
{
	vector<string> MailVec;
	int num=0;
	string tempfile;
	WIN32_FIND_DATA FindFileData;
	HANDLE hFind;
	BOOL result,fFinished = FALSE;
	string strPath = mailDir+"\\";
	string strFileEx;
	strFileEx = strPath+"*.txt";
	hFind = FindFirstFile( strFileEx.c_str(),&FindFileData );
	if( hFind == INVALID_HANDLE_VALUE )
		cerr<<"Error: there is no .txt files in this directory!"<<endl;
	else
	{
		num++;
		tempfile = FindFileData.cFileName;
		MailVec.push_back( tempfile );
	}
	while( !fFinished )
	{
		result = FindNextFile( hFind, &FindFileData );
		if( !result )
		{			
			if (GetLastError() == ERROR_NO_MORE_FILES) 
			{								
				cout<<"There are total "<<num<<" new mail to classify!"<<endl;
				fFinished = TRUE; 
			} 
			else 
			{ 
				cerr<<"Couldn't find next file."<<endl; 
			} 
		}
		else
		{
			num++;
			tempfile = FindFileData.cFileName;
			MailVec.push_back( tempfile );
		}
	}
	return MailVec;
} 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?