#include <iostream>
#include <vector>
#include <io.h>
//封装函数
//遍历文件夹获取各文件名称并筛选指定格式的文件
void get_need_file(string path, vector<string>& file, string ext)
{
intptr_t file_handle = 0;
struct _finddata_t file_info;
string temp;
if ((file_handle = _findfirst(temp.assign(path).append("/*" + ext).c_str(), &file_info)) != -1)
{
do
{
file.push_back(temp.assign(path).append("/").append(file_info.name));
} while (_findnext(file_handle, &file_info) == 0);
_findclose(file_handle);
}
}
//函数使用
//string file_path = R"(E:\Test)";//文件夹路径
vector<string> my_file;
string need_extension = ".dat";//文件后缀类型
//获取文件夹里面函数
get_need_file(file_path , my_file, need_extension);
UF_UI_open_listing_window();
for (int i = 0; i < my_file.size(); i++)
{
UF_UI_write_listing_window(my_file[i].c_str());//输出
print("\n");
}
if (my_file.size() == 0)
{
//cout << "No file can be found!" << endl;
uc1601("没有模板文件", 1);
}
else
{
UF_UI_write_listing_window("dat文件数量");
UF_UI_write_listing_window(my_file.size();
}