c++ 遍历文件夹下的所有文件

180it 2020-10-08 PM 1463℃ 0条
#include <stdio.h>
#include <io.h>
#include <string>
 
int main()
{
    //目标文件夹路径
    std::string inPath = "E:\\RuiJie\\VedioCapture\\2018-08-28 11-06-35\\*.jpg";//遍历文件夹下的所有.jpg文件
    //用于查找的句柄
    long handle;
    struct _finddata_t fileinfo;
    //第一次查找
    handle = _findfirst(inPath.c_str(), &fileinfo);
    if (handle == -1)
        return -1;
    do
    {
        //找到的文件的文件名
        printf("%s\n", fileinfo.name);
 
    } while (!_findnext(handle, &fileinfo));
 
    _findclose(handle);
    system("pause");
    return 0;
}

支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

c++ 遍历文件夹下的所有文件