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的更多相关文章

  1. python_自动查找指定目录下的文件或目录的方法

    代码如下 import os def find_file(search_path, file_type="file", filename=None, file_startswith ...

  2. python查找指定目录下所有文件,以及改文件名的方法

    一: os.listdir(path) 把path目录下的所有文件保存在列表中: >>> import os>>> import re>>> pa ...

  3. 运维笔记--Linux查找指定目录下某段时间的文件

    查找指定目录下,60天之前的文件:find /mnt/xml_data -mtime +60 -name "*.xml" 找到并统计数量:find /mnt/xml_data -m ...

  4. C++查找指定目录下所以指定类型的文件

    /*************************************************************** 函数名称:FindFile 查找指定目录下指定文件 输入:fileNa ...

  5. [bash]查找指定目录下符合格式的txt文件

    需求: 查找指定目录下符合yyyy-MM-dd(-b)NNN.txt格式的文件,如“2020-03-22-b888.txt” 目标目录内容: [root@localhost bashs]# ll /r ...

  6. iOS案例:读取指定目录下的文件列表

    // // main.m // 读取指定目录下的文件列表 // // Created by Apple on 15/11/24. // Copyright © 2015年 Apple. All rig ...

  7. 初识TypeScript:查找指定路径下的文件按类型生成json

    如果开发过node.js的话应该对js(javascript)非常熟悉,TypeScript(以下简称ts)是js的超集. 下面是ts的官网: https://www.tslang.cn/ 1.环境配 ...

  8. PHP 获取指定目录下所有文件(包含子目录)

    PHP 获取指定目录下所有文件(包含子目录) //glob — 寻找与模式匹配的文件路径 $filter_dir = array('CVS', 'templates_c', 'log', 'img', ...

  9. python glob 用通配符查找指定目录中的文件 - 开源中国社区

    python glob 用通配符查找指定目录中的文件 - 开源中国社区 python glob 用通配符查找指定目录中的文件

随机推荐

  1. Spring整合JUnit4测试

    @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"classpath:spring/ap ...

  2. 初识CentOS服务命令大全

    (1)系统架构 查看内核 # uname -s -r Linux 2.6.32-358.el6.x86_64 查看发布版本 # cat /etc/redhat-release CentOS relea ...

  3. iOS:核心动画之转场动画CATransition

    转场动画——CATransition CATransition是CAAnimation的子类,用于做转场动画,能够为层提供移出屏幕和移入屏幕的动画效果.iOS比Mac OS X的转场动画效果少一点 U ...

  4. log log4net用代码记录日志

    log4net  用代码记录日志 今天在开发项目的时候,遇到跨域调用log4net中的类,出现了一个bug,提示LogImpl未标记可序列化,此时,我靠,麻烦了,这个类又不是咱们自己的,改源码我想应该 ...

  5. C# 数组、一维数组、二维数组、多维数组、锯齿数组

    C#  数组.一维数组.二维数组.多维数组.锯齿数组 一.数组: 如果需要使用同一类型的对象,就可以使用数组,数组是一种数据结构,它可以包含同一类型的多个元素.它的长度是固定的,如长度未知的情况下,请 ...

  6. ARC的内存管理

        在objective-c中,内存的引用计数一直是一个让人比较头疼的问题.尤其是当引用计数涉及到arc.blocks等等的时候.似乎ARC的出现只是让我们解放了双手,由于底层实现依然依赖引用计数 ...

  7. Android findBugs

    1.Bug:DM_BOXED_PRIMITIVE_FOR_PARSING "Boxing/unboxing to parse a primitive", A boxed primi ...

  8. 【笨嘴拙舌WINDOWS】GDI映射方式

    TextOut(hdc,100,100,TEXT(“Love China”),10) 这句GDI函数的作用是在坐标点(100,100)的位置输出一个“Love China”字符串: GDI函数作为硬件 ...

  9. visual studio 2015常用快捷键

    常用快捷键 技巧 0.0 删除文件中的当前行: Home + Shife-End + Delete 技巧 1.1 避免意外复制一个空白行 工具->选项->文本编辑器->所有语言-&g ...

  10. POJ 2236 (简单并查集) Wireless Network

    题意: 有n个电脑坏掉了,分别给出他们的坐标 有两种操作,可以O x表示修好第x台电脑,可以 S x y表示x y是否连通 两台电脑的距离不超过d便可连通,两台电脑是连通的可以直接连通也可以间接通过第 ...