查找指定目录下的文件 .xml
pre{
line-height:1;
color:#9f1d66;
background-color:#cfe4e4;
font-size:16px;}.sysFunc{color:#5d57ff;font-style:italic;font-weight:bold;}
.selfFuc{color:#8e0ed3;}
.bool{color:#008000;}
.condition{color:#008000;font-weight:bold;}
.key{color:#440080;}
.var{color:#008000;font-style:italic;}
.Digit{color:#000080;font-weight:bold;}
.includePre{color:#661d9f;}
.operator {color:#fd1a53;font-weight:bold;}
使用CFindFile类, 此类主要是用来查找文件的,首先调用 FindFile() 函数 ,来开始查找过程,然后调用FindNextFile来得到后续的文件信息等。
注意: 此类在vs控制台下不能编译成功,只能在MFC运行才可以
MSDN中的解释为:
Call this member function to open a file search.
virtual BOOL FindFile(
LPCTSTR pstrName = NULL,
DWORD dwUnused = 0
);
例子:
Example
This small program recurses every directory on the C:/ drive and prints the name of the directory.
#include <afxwin.h>
#include <iostream>
using namespace std;
void Recurse(LPCTSTR pstr)
{
CFileFind finder;
// build a string with wildcards
CString strWildcard(pstr);
strWildcard += _T("//*.*");
// start working for files
BOOL bWorking = finder.FindFile(strWildcard);
while (bWorking)
{
bWorking = finder.FindNextFile();
// skip . and .. files; otherwise, we'd
// recur infinitely!
if (finder.IsDots())
continue;
// if it's a directory, recursively search it
if (finder.IsDirectory())
{
CString str = finder.GetFilePath();
cout << (LPCTSTR) str << endl;
Recurse(str);
}
}
finder.Close();
}
int main()
{
if (!AfxWinInit(GetModuleHandle(NULL), NULL, GetCommandLine(), 0))
cout << "panic!" << endl;
else
Recurse(_T("C:"));
}
其它网络资料:
现有很多优化软件 在做删除 系统冗余文件时 会把LJ文件的名字 显示在一个列表中 供用户删除.
这就用到了遍历文件夹下所有文件的技术了. 于是就像自己写一个出来. 但以前都没接触过 所以查了下MSDN 输入 findfile尽然有这样的函数 暗喜还有代码实例 稍微改了下一点点的代码 如果再修改下 可以做成删除特定的一组文件也可以自己做一个删除系统LJ的软件 有待大家去发挥想像力了
对此函数说明如下:
Call this member function to open a file search.
virtual BOOL FindFile(
LPCTSTR pstrName = NULL,
DWORD dwUnused = 0
);
After calling FindFile to begin the file search, call FindNextFile to retrieve subsequent files. You must call FindNextFile at least once before calling any of the following attribute member functions:
说的是此函数用于开始一个文件查找,当查找到之后,可以调用FindNextFile连续得查找一组文件
#include <afxwin.h>
#include <iostream>
using namespace std;
void Recurse(LPCTSTR pstr)
{
CFileFind finder;
// build a string with wildcards
CString strWildcard(pstr);
strWildcard += _T("//*.*");
// start working for files
BOOL bWorking = finder.FindFile(strWildcard);
while (bWorking)
{
bWorking = finder.FindNextFile();
// skip . and .. files; otherwise, we'd
// recur infinitely!
if (finder.IsDots())
continue;
CString sFileName = finder.GetFileName();
cout << (LPCTSTR)sFileName << endl;//输出查找文件夹下的所有文件名
}
finder.Close();
}
int main()
{
if (!AfxWinInit(GetModuleHandle(NULL), NULL, GetCommandLine(), 0))//初始化MFC
cout << "panic!" << endl;
else
Recurse(_T("C:"));
return 0;
}
本文使用 书画小说软件 发布,内容与软件无关,书画小说软件 更惬意的读、更舒心的写、更轻松的发布。
查找指定目录下的文件 .xml的更多相关文章
- python_自动查找指定目录下的文件或目录的方法
代码如下 import os def find_file(search_path, file_type="file", filename=None, file_startswith ...
- python查找指定目录下所有文件,以及改文件名的方法
一: os.listdir(path) 把path目录下的所有文件保存在列表中: >>> import os>>> import re>>> pa ...
- 运维笔记--Linux查找指定目录下某段时间的文件
查找指定目录下,60天之前的文件:find /mnt/xml_data -mtime +60 -name "*.xml" 找到并统计数量:find /mnt/xml_data -m ...
- C++查找指定目录下所以指定类型的文件
/*************************************************************** 函数名称:FindFile 查找指定目录下指定文件 输入:fileNa ...
- [bash]查找指定目录下符合格式的txt文件
需求: 查找指定目录下符合yyyy-MM-dd(-b)NNN.txt格式的文件,如“2020-03-22-b888.txt” 目标目录内容: [root@localhost bashs]# ll /r ...
- iOS案例:读取指定目录下的文件列表
// // main.m // 读取指定目录下的文件列表 // // Created by Apple on 15/11/24. // Copyright © 2015年 Apple. All rig ...
- 初识TypeScript:查找指定路径下的文件按类型生成json
如果开发过node.js的话应该对js(javascript)非常熟悉,TypeScript(以下简称ts)是js的超集. 下面是ts的官网: https://www.tslang.cn/ 1.环境配 ...
- PHP 获取指定目录下所有文件(包含子目录)
PHP 获取指定目录下所有文件(包含子目录) //glob — 寻找与模式匹配的文件路径 $filter_dir = array('CVS', 'templates_c', 'log', 'img', ...
- python glob 用通配符查找指定目录中的文件 - 开源中国社区
python glob 用通配符查找指定目录中的文件 - 开源中国社区 python glob 用通配符查找指定目录中的文件
随机推荐
- 【转】RESTful Web Services初探
近几年,RESTful Web Services渐渐开始流行,大量用于解决异构系统间的通信问题.很多网站和应用提供的API,都是基于RESTful风格的Web Services,比较著名的包括Twit ...
- SSIS -->> Variable Data Type vs SSIS Data Type
变量和参数的数据类型一致,只是参数比变量少了诸如object这种可选类型.和SSIS数据类型的映射关系
- jstl long类型数据转换为日期格式
一.有WEB-INF下建立一个datetag.tld <?xml version="1.0" encoding="UTF-8"?> <tagl ...
- code manager tools svn服务安装配置
svn server 安装配置: 下载地址:http://www.visualsvn.com/server/download/ 然后安装图一步一步前进: 1.点击download now: 2.点击N ...
- 【Tech】YCSB-0.1.3安装使用
1. 下载YCSB 0.1.3: wget https://github.com/brianfrankcooper/YCSB/archive/0.1.3.tar.gz 如果提示“wget:命令没找到” ...
- 《OD学hadoop》Linux基础
一.Linux基本环境 1. Linux常见版本及VMware虚拟机安装Linux系统 2. 虚拟机网络配置(IP地址.主机名.防火墙) 3. 文件基本命令操作 4. 四大远程连接工具使用 二.Lin ...
- Searching in a Radius using Postgres[Marked]
Searching in a Radius using Postgres Creating a GEO application has never been easier. You can have ...
- 坏账,断供,四大国有资产管理公司(AMC):东方、长城、信达和华融
在高房价大幅度下降以后,银行会认为你在贷款的时候的抵押物,已经不值钱了,比如已经下跌百分之五十了,那么,银行就会给贷款者一个通知——你的抵押物--房子,已经不值钱了,所以说,你必须立刻缴纳这一部分贬值 ...
- [ionic开源项目教程] - 第11讲 封装BaseController实现controller继承
关注微信订阅号:TongeBlog,可查看[ionic开源项目]全套教程. 截止到第10讲,tab1[健康]模块的功能基本已经完成了,但这一讲中,controller层又做了较大的改动,因为下一讲中t ...
- UVa 514 (stack的使用) Rails
练习一下stack的使用,还有要注意一下输入的格式,看了好长时间没懂. //#define LOCAL #include <iostream> #include <cstdio> ...