c++获取某一目录下的所有文件

来源:互联网 发布:php添加功能的按钮 编辑:程序博客网 时间:2024/06/06 04:18
#include <dirent.h>void FindFiles(string root ,vector<string> &files){    DIR *dir;    struct dirent *ent;    if ((dir = opendir (root.c_str())) != NULL) {        while ((ent = readdir (dir)) != NULL) {            if(!strcmp(ent->d_name,".")||!strcmp(ent->d_name,".."))                continue;            files.push_back(ent->d_name);        }        closedir (dir);    }}
原创粉丝点击