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. centos7 安装 mysql5.6(MySQL-5.6.44-1.el7.x86_64.rpm-bundle.tar)

    1.卸载MariaDB rpm -qa | grep -i mariadb rpm -e --nodeps mariadb-libs--.el7.x86_64 2.卸载已有Mysql 卸载旧版本mys ...

  2. Hadoop hadoop的介绍和几种模式

    Hadoop简介 Hadoop软件库是一个开源框架,允许使用简单的编程模型跨计算机集群分布式处理大型数据集.它旨在从单个服务器扩展到数千台计算机,每台计算机都提供本地计算和存储.库本身不是依靠硬件来提 ...

  3. markdown文件的基本常用编写语法

    .md即markdown文件 1.标题的几种写法: 第一种:     前面带#号,后面带文字,分别表示h1-h6,上图可以看出,只到h6,而且h1下面会有一条横线,注意,#号后面有空格 第二种:   ...

  4. docker - nginx+php+php-mysql(扩展)

    Docker 安装 Nginx(https://www.runoob.com/docker/docker-install-nginx.html) Docker 安装 PHP(https://www.r ...

  5. Linux中显示系统中USB信息的lsusb命令

    来源:Linux中国  原文:https://linux.cn/article-2448-1.html 通用串行总线(USB)被设计成为连接计算机外设的标准,如键盘.鼠标.打印机.数码相机.便携式媒体 ...

  6. AT1357 n^p mod m(洛谷)

    题意翻译 求 n^p mod m 的值 输入格式 一行,为整数 n,m,p(注意顺序) 输出格式 一行,为 n^p mod m 的值 数据说明 对于100%的数据 1≤n,m≤10^91≤n,m≤10 ...

  7. VUE判断可用对象是否为空

    方法一: JSON.stringify(formmanage_listVue.updataObj)=='{}' var data = {}; var b = (JSON.stringify(data) ...

  8. xss绕过姿势

    #未完待续... 00x1.绕过 magic_quotes_gpc magic_quotes_gpc=ON 是php中的安全设置,开启后会把一些特殊字符进行轮换, 比如: ' 会被转换为 \' 再比如 ...

  9. java-mybaits-013-mybatis-Interceptor-拦截器执行顺序

    一.概述 已知拦截器能够拦截四种类型:Executor.ParameterHandler.ResultSetHandler.StatementHandler. 1.1.不同类型拦截器的执行顺序 背景: ...

  10. Flutter中的事件广播event_bus的基本使用

    官方包参考地址: https://pub.dev/packages/event_bus https://github.com/marcojakob/dart-event-bus 1.pubspec.y ...