VC++实现遍历指定文件夹,并进行深度遍历,一级,二级。。。最终列出该文件夹下所有文件全路径。

#include "stdafx.h"
#include <iostream>
#include <Windows.h> using namespace std; /************************************
@ Brief: 判断文件是否存在
@ Author: woniu201
@ Created: 2018/09/12
@ Return:
************************************/
BOOL IsDirExist(char* csDir)
{
DWORD dwAttrib = GetFileAttributes(csDir);
return INVALID_FILE_ATTRIBUTES != dwAttrib && 0 != (dwAttrib & FILE_ATTRIBUTE_DIRECTORY);
} /************************************
@ Brief: 遍历文件夹
@ Author: woniu201
@ Created: 2018/09/13
@ Return:
************************************/
BOOL DirectoryList(char* path)
{
WIN32_FIND_DATA FindData;
HANDLE handle; char fullName[2048] = {0}; char filePathName[2048] = {0};
strcpy(filePathName, path);
strcat(filePathName, "\\*.*");
handle = FindFirstFile(filePathName, &FindData);
if (handle == INVALID_HANDLE_VALUE)
{
cout << "搜索失败" << endl;
}
while(FindNextFile(handle, &FindData))
{
//过滤.和..
if (strcmp(FindData.cFileName, ".") == 0 || strcmp(FindData.cFileName, "..") == 0)
{
continue;
} sprintf(fullName, "%s\\%s", path, FindData.cFileName);
cout << fullName << endl; //判断是否是文件夹
if (IsDirExist(fullName))
{
DirectoryList(fullName);
}
}
FindClose(handle);
return TRUE;
} int _tmain(int argc, _TCHAR* argv[])
{
DirectoryList("c:\\");
getchar();
return 0;
}

VC++实现遍历指定文件夹的更多相关文章

  1. C#遍历指定文件夹中的所有文件(转)

    原文链接:http://www.cnblogs.com/qianqianfy/archive/2009/07/08/1518974.html 1. C#遍历指定文件夹中的所有文件 DirectoryI ...

  2. C#遍历指定文件夹中的所有文件(转)

    C#遍历指定文件夹中的所有文件 DirectoryInfo TheFolder=new DirectoryInfo(folderFullName);//遍历文件夹foreach(DirectoryIn ...

  3. Java 遍历指定文件夹及子文件夹下的文件

    Java 遍历指定文件夹及子文件夹下的文件 /** * 遍历指定文件夹及子文件夹下的文件 * * @author testcs_dn * @date 2014年12月12日下午2:33:49 * @p ...

  4. Jquery EasyUI tree 的异步加载(遍历指定文件夹,根据文件夹内的文件生成tree)

    private void SMT(HttpContext context) { string SqlConnection82 = System.Configuration.ConfigurationM ...

  5. C#遍历指定文件夹中的所有文件和子文件夹

    参考:http://www.cnblogs.com/skylaugh/archive/2012/09/23/2698850.html DirectoryInfo TheFolder=new Direc ...

  6. C#遍历指定文件夹中的所有文件

    DirectoryInfo TheFolder=new DirectoryInfo(folderFullName);//遍历文件夹foreach(DirectoryInfo NextFolder in ...

  7. PHP递归遍历指定文件夹内的文件

    今天早上在地铁上看了关于文件和文件夹的一章,正好最近刚搞懂linux的文件系统,觉得对文件属性的访问跟Shell命令很像,所以想晚上来实践一下. 发现php的文件夹函数好像没有提供遍历文件夹下的所有文 ...

  8. Python3遍历指定文件夹下所有文件及文件夹

    采用os模块儿: import os def get_filelist(dir): for home, dirs, files in os.walk(dir): print("####### ...

  9. C# 读取指定文件夹中的全部文件,并按规则生成SQL语句!

    本实例的目的在于: 1 了解怎样遍历指定文件夹中的全部文件 2 控制台怎样输入和输出数据 代码: using System; using System.IO; namespace ToSql{ cla ...

随机推荐

  1. Java 8的Time包常用API

    Date.Canlender.SimpleDateFormat类在新的Time包面前几乎没有优势 日期LocalDate,时间LocalTime,日期时间LocalDateTime. 时区ZoneId ...

  2. 判断List<E>内是否有重复对象

    主要用到Java 8的Stream类 long distinctedSize = list.stream().distinct().count(); boolean hasRepeat = list. ...

  3. CF1174D Ehab and the Expected XOR Problem(二进制)

    做法 求出答案序列的异或前缀和\(sum_i\),\([l,r]\)子段异或和可表示为\(sum_r\bigoplus sum_{l-1}\) 故转换问题为,填\(sum\)数组,数组内的元素不为\( ...

  4. python3 系统监控脚本(CPU,memory,网络,disk等)

    #!/usr/bin/env python3 #create at 2018-11-30 'this is a system monitor scripts' __author__="yjt ...

  5. Coroutine 协程

    https://en.wikipedia.org/wiki/Coroutine Coroutines are computer program components that generalize s ...

  6. NTC热敏电阻温度计算方法,Steinhart-Hart方程和B值法(转)

    NTC热敏电阻计算器使用方法 NTC热敏电阻计算器 V1.0 10K负温度系数热敏电阻(NTC)温度与阻值对应关系表 Rt = R(25℃)*EXP[B*(1/T - 1/(T+25))] 说明: 1 ...

  7. E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem. 爆错解决办法

    author  :headsen chen date : 2019-06-06  10:09:06 root@ubuntu:~# apt-get remove java-1.8.0-openjdk E ...

  8. keras Model 1 入门篇

    1 入门 2 多个输入和输出 3 共享层 最近在学习keras,它有一些实现好的特征提取的模型:resNet.vgg.而且是带权重的.用来做特诊提取比较方便 首先要知道keras有两种定义模型的方式: ...

  9. leetcode 62. Unique Paths 、63. Unique Paths II

    62. Unique Paths class Solution { public: int uniquePaths(int m, int n) { || n <= ) ; vector<v ...

  10. OneDrive

    OneDrive https://onedrive.live.com