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. swift:创建九宫格

    九宫格的创建是有规律可循的,每一个格子的水平和竖直方向的间隔是固定的,通过计算每一个格子的位置,然后把它们依次放到视图中即可. 一般的步骤为: 1.设置格子的总个数和每一列的格子数 2.求格子的间隔: ...

  2. BI

    http://www.cnblogs.com/biwork/p/3276455.html http://www.cnblogs.com/biwork/p/3328879.html http://www ...

  3. Iterator的remove方法可保证从源集合中安全地删除对象(转)

    如果对正在被迭代的集合进行结构上的改变(即对该集合使用add.remove或clear方法),那么迭代器就不再合法(并且在其后使用该迭代器将会有ConcurrentModificationExcept ...

  4. Data Base Oracle下载及安装

    Oracle   下载及安装 一.官方下地址:   http://www.oracle.com/technetwork/database/enterprise-edition/downloads/in ...

  5. jQuery练习一好友列表变色

    多选 选中变色 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www ...

  6. 操刀 requirejs,自己动手写一个

    前沿 写在文章的最前面 这篇文章讲的是,我怎么去写一个 requirejs . 去 github 上fork一下,顺便star~ requirejs,众所周知,是一个非常出名的js模块化工具,可以让你 ...

  7. Ubuntu14.04安装和配置Tomcat8.0.12

    Ubuntu14.04长的好看,所以一时间很感兴趣,研究各种软件的安装和开发环境的配置.今天先把安装的tomcat 8.0.12的教程分享给大家.如果你需要,请收藏!!!   官方网站下载最新的tom ...

  8. cdoj 1324 卿学姐与公主 线段树裸题

    卿学姐与公主 Time Limit: 2000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit St ...

  9. 浅谈javascript中的作用域

    首先说明一下:Js中的作用域不同于其他语言的作用域,要特别注意     JS中作用域的概念: 表示变量或函数起作用的区域,指代了它们在什么样的上下文中执行,亦即上下文执行环境.Javascript的作 ...

  10. ubuntu 搭建Erlang开发环境

    首先,打好库: sudo apt-get install build-essential sudo apt-get install libncurses5-dev sudo apt-get insta ...