windows中遍历指定文件夹下的所有子文件夹
来源:互联网 发布:满档红帽哥布林数据 编辑:程序博客网 时间:2024/06/05 04:37
前面我给出了windows下面指定文件夹下面指定类型文件的遍历程序,这里,再给出遍历指定文件夹下的所有子文件夹的程序:
#include "stdafx.h"#include <Windows.h>#include <vector>#include <string>#include "iostream"using namespace std; int GetSubFolders(string& folder, vector<string>& subFolders ){ subFolders.clear(); WIN32_FIND_DATAA fileFindData; string nameWC = folder + "//*"; HANDLE hFind = ::FindFirstFileA(nameWC.c_str(), &fileFindData); if (hFind == INVALID_HANDLE_VALUE) { cout<<"folder path error...."<<endl; system("pause"); return 0; } do { if (fileFindData.cFileName[0] == '.') { continue; // filter the '..' and '.' in the path } if (fileFindData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY) { subFolders.push_back(folder+"//"+fileFindData.cFileName); } } while (::FindNextFileA(hFind, &fileFindData)); FindClose(hFind); return (int)subFolders.size();} int _tmain(int argc, _TCHAR* argv[]){ string folder = "c://OpenCV"; vector<string> subDir; int count = GetSubFolders(folder, subDir); cout<<"count = "<<count<<endl; for (int i=0; i<count; i++) { cout<<subDir[i].c_str()<<endl; } system("pause"); return 0;}
from: http://blog.csdn.net/carson2005/article/details/6327375
0 0
- windows中遍历指定文件夹下的所有子文件夹
- windows中遍历指定文件夹下的所有子文件夹
- windows中遍历指定文件夹下的所有子文件夹
- 遍历指定文件夹下的子文件夹和其所有子文件
- 非递归遍历指定文件夹下的所有文件及其子文件夹
- windows 遍历文件夹及子文件夹的所有
- Android 遍历删除SD卡中某一文件夹下的指定子文件夹及其子文件
- 遍历一个文件夹下所有的文件和子文件夹
- 遍历一个文件夹下的所有文件和子文件夹
- 遍历一个文件夹下的所有文件和子文件夹
- 遍历文件夹 下的所有文件 ,包括子文件夹
- 遍历读取指定文件夹下指定类型的所有文件
- 遍历读取指定文件夹下指定类型的所有文件
- 遍历文件夹下的文件夹和子文件,遍历文件夹删除文件夹及其下面的所有子文件
- VC中遍历文件夹下的文档及子文件夹
- VC中遍历文件夹下的文档及子文件夹 .
- VC中遍历文件夹下的文档及子文件夹
- c++遍历指定文件夹下的所有的文件
- Linuxc编程的常用关键字 register ,static ,extern ,const ,typedef
- 事务四大特征:原子性,一致性,隔离性和持久性(ACID)
- 父子控制器
- putty 使用之psftp.exe,远程服务器和本机之间上传下载。
- Windows下的包管理器Chocolatey
- windows中遍历指定文件夹下的所有子文件夹
- 二叉排序数的基本操作(构造、插入、删除)
- PHP代码调试
- linux 下基本的I/O系统函数
- NYOJ 812 水题 十进制 二进制 转换
- hdu 3631 Shortest Path floyd 解题报告
- iOS——教你如何使用ReactiveCocoa和MVVM为代码解耦构建清爽APP
- Ubuntu 删除个人配置文件
- 匹配汉字的正则表达式