获取指定目录下所有的文件名

	// 获得目录下的所有文件列表
	vector<CString> _vecFileName;
	CString _strPath;
	_strPath = "c:\\";
	CFileFind _finder;
	BOOL _bFind = _finder.FindFile(_strPath + "*.*");
	while (_bFind)
	{
		_bFind = _finder.FindNextFile();
		if (_finder.IsDots())
		{
			continue;
		}

		if (_finder.IsDirectory())
		{
			continue;
		}
	
		CString _strFileName;
		_strFileName =  _finder.GetFileName();
		if (_strFileName.Find(_T(".jpg"), 0) >= 0 || 
			_strFileName.Find(_T(".JPG"), 0) >= 0)
		{
			_strFileName = _strPath + _strFileName;
			_vecFileName.push_back(_strFileName);
		}
	}

猜你喜欢

转载自blog.csdn.net/zy499/article/details/53022819