获取Windows某一目录下的所有文件名

Posted fosonR

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获取Windows某一目录下的所有文件名相关的知识,希望对你有一定的参考价值。

#include <sys/types.h>
#include <dirent.h>
 
 
std::vector<std::string> get_all_filename(char* dirname)
{
     DIR *dp;
     struct dirent* dirp;
     std::vector<std::string> filename_vector;
     if((dp = opendir(dirname)) == NULL)
     {
          printf("this dir maybe not exist");
     }
     while((dirp = readdir(dp)) != NULL)
     {
          filename_vector.push_back(dirp->d_name);
     }
     closedir(dp);
     return filename_vector;
}

以上是关于获取Windows某一目录下的所有文件名的主要内容,如果未能解决你的问题,请参考以下文章