美文网首页
c++遍历目录

c++遍历目录

作者: c之气三段 | 来源:发表于2023-05-25 15:12 被阅读0次
    getAllResultFiles(std::string path, std::vector<std::string>& files)
    {
        struct _finddata_t fileinfo;
        intptr_t hFile = _findfirst(path.append("\\*").c_str(), &fileinfo);
    
        if (hFile == -1) {
            return;
        }
        do
        {
            if (fileinfo.attrib & _A_SUBDIR)
            {
                //if ((strcmp(fileinfo.name, ".") != 0) && (strcmp(fileinfo.name, "..") != 0))//忽略.或..
                //{
                //目录             
                //}
            }
            else//文件
            {
            files.push_back(fileinfo.name);
            }
    
        } while (_findnext(hFile, &fileinfo) == 0);
        _findclose(hFile);
    }
    

    相关文章

      网友评论

          本文标题:c++遍历目录

          本文链接:https://www.haomeiwen.com/subject/wpawhdtx.html