VC++实现遍历指定文件夹
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++实现遍历指定文件夹的更多相关文章
- C#遍历指定文件夹中的所有文件(转)
原文链接:http://www.cnblogs.com/qianqianfy/archive/2009/07/08/1518974.html 1. C#遍历指定文件夹中的所有文件 DirectoryI ...
- C#遍历指定文件夹中的所有文件(转)
C#遍历指定文件夹中的所有文件 DirectoryInfo TheFolder=new DirectoryInfo(folderFullName);//遍历文件夹foreach(DirectoryIn ...
- Java 遍历指定文件夹及子文件夹下的文件
Java 遍历指定文件夹及子文件夹下的文件 /** * 遍历指定文件夹及子文件夹下的文件 * * @author testcs_dn * @date 2014年12月12日下午2:33:49 * @p ...
- Jquery EasyUI tree 的异步加载(遍历指定文件夹,根据文件夹内的文件生成tree)
private void SMT(HttpContext context) { string SqlConnection82 = System.Configuration.ConfigurationM ...
- C#遍历指定文件夹中的所有文件和子文件夹
参考:http://www.cnblogs.com/skylaugh/archive/2012/09/23/2698850.html DirectoryInfo TheFolder=new Direc ...
- C#遍历指定文件夹中的所有文件
DirectoryInfo TheFolder=new DirectoryInfo(folderFullName);//遍历文件夹foreach(DirectoryInfo NextFolder in ...
- PHP递归遍历指定文件夹内的文件
今天早上在地铁上看了关于文件和文件夹的一章,正好最近刚搞懂linux的文件系统,觉得对文件属性的访问跟Shell命令很像,所以想晚上来实践一下. 发现php的文件夹函数好像没有提供遍历文件夹下的所有文 ...
- Python3遍历指定文件夹下所有文件及文件夹
采用os模块儿: import os def get_filelist(dir): for home, dirs, files in os.walk(dir): print("####### ...
- C# 读取指定文件夹中的全部文件,并按规则生成SQL语句!
本实例的目的在于: 1 了解怎样遍历指定文件夹中的全部文件 2 控制台怎样输入和输出数据 代码: using System; using System.IO; namespace ToSql{ cla ...
随机推荐
- 支持utf8的str_split函数
<?php header("Content-type: text/html; charset=utf-8"); /** * 按字节数对字符串进行分片 * @param $st ...
- JavaScript 字符串转数字(整数,浮点数,进制转换)
下面是使用parseFloat()方法的示例: parseFloat("1234blue"); //returns 1234.0 parseFloat("0xA" ...
- Spring Cloud Gateway(六):路由谓词工厂 RoutePredicateFactory
本文基于 spring cloud gateway 2.0.1 1.简介 Spring Cloud Gateway 创建 Route 对象时, 使用 RoutePredicateFactory 创建 ...
- mybatis 集合in的用法
<!-- 查询 设备List 的 某天,并且小于当前小时的,耗电 记录 --> <select id="findByDeviceIdInAndBetweenRecor ...
- MovingWallVelocity边界条件【翻译】
翻译自:CFD-online 帖子地址:http://www.cfd-online.com/Forums/openfoam-solving/59646-movingwallvelocity-bound ...
- buoyantSimpleFoam求解器:恒热流壁面【翻译】
翻译自:CFD-online 帖子地址:http://www.cfd-online.com/Forums/openfoam-solving/148183-buoyantsimplefoam-fixed ...
- 【原】Python基础-函数
#不定长参数,这里prams是一个元组集合def print_params(*prams): for e in prams: print(e) print(prams) #输出('xxx', (1, ...
- springboot集成Kafka
kafka和MQ的区别: 1)在架构模型方面, RabbitMQ遵循AMQP协议,RabbitMQ的broker由Exchange,Binding,queue组成,其中exchange和binding ...
- 2018-2019-2 《网络对抗技术》Exp8 Web基础 Week11-12 20165233
Exp8 Web基础 目录 一.基础问题 二.实验步骤 实验点一:Web前端HTML 能正常安装.启停Apache.理解HTML,理解表单,理解GET与POST方法,编写一个含有表单的HTML. 实验 ...
- php接口数据安全解决方案(一)
前言 目录介绍 登录鉴权图 接口请求安全性校验整体流程图 代码展示 演示用户登录 演示获取用户信息 文章完整代码地址 后记 前言 目的: 1.实现前后端代码分离,分布式部署 2.利用token替代se ...