文件夹查找操作 CFileFind类的IsDots()和IsDictionary()函数
2017-01-04 16:21
197 查看
转载来自:http://blog.sina.com.cn/s/blog_518e9d610100qm43.html
1、IsDots:
Call this member function to test for the current directory and parent directory markers while iterating through files.
Nonzero if the found file has the name "." or "..", which indicates that the found file is actually a directory. Otherwise 0.
其中在每个文件夹下都有两个默认的文件夹,用来指示当前目录,或者上一级目录,其中.指示当前目录,..表示上一级目录。
2、IsDictionary():判断一个文件是否是一个目录(文件夹)。
这两个函数主要用在文件夹的遍历上,用来判断三类类型:文件,普通文件夹,..或者.文件夹。
常用的使用模式为:
bool b=file.FindFile(strDirectoryname)
while(b)
{
b=file.FindNextFile(strDirectoryname);
//文件的处理方式
if(!file.IsDots() && !file.IsDirectory)
{}
//..和.文件的处理一般为continue;
else
if(file.IsDots())
{
continue;
}
//文件夹(目录)的处理方式
else
if(file.IsDirectory())
{}
}
实验程序:
CFileFind files;
CString strparent = _T("E:\\ymrf2\\videochannels\\vv2\\vv2\\vv2\\v2\\*.264");
BOOL looking = files.FindFile(strparent);
int i=0;
CString str;
while (looking)
{
looking = files.FindNextFile();
if (files.IsDots())
continue;
if (files.IsDirectory())
continue;
i++;
}
str.Format(_T("%d"), i);
SetDlgItemText(IDC_EDIT1, str);
1、IsDots:
Call this member function to test for the current directory and parent directory markers while iterating through files.
Nonzero if the found file has the name "." or "..", which indicates that the found file is actually a directory. Otherwise 0.
其中在每个文件夹下都有两个默认的文件夹,用来指示当前目录,或者上一级目录,其中.指示当前目录,..表示上一级目录。
2、IsDictionary():判断一个文件是否是一个目录(文件夹)。
这两个函数主要用在文件夹的遍历上,用来判断三类类型:文件,普通文件夹,..或者.文件夹。
常用的使用模式为:
bool b=file.FindFile(strDirectoryname)
while(b)
{
b=file.FindNextFile(strDirectoryname);
//文件的处理方式
if(!file.IsDots() && !file.IsDirectory)
{}
//..和.文件的处理一般为continue;
else
if(file.IsDots())
{
continue;
}
//文件夹(目录)的处理方式
else
if(file.IsDirectory())
{}
}
实验程序:
CFileFind files;
CString strparent = _T("E:\\ymrf2\\videochannels\\vv2\\vv2\\vv2\\v2\\*.264");
BOOL looking = files.FindFile(strparent);
int i=0;
CString str;
while (looking)
{
looking = files.FindNextFile();
if (files.IsDots())
continue;
if (files.IsDirectory())
continue;
i++;
}
str.Format(_T("%d"), i);
SetDlgItemText(IDC_EDIT1, str);
相关文章推荐
- asp下利用fso实现文件夹或文件移动改名等操作函数
- 如何利用系统函数操作文件夹及文件
- 标准I/O常用函数以及Linux文件夹操作函数
- php文件夹与文件目录操作函数介绍
- php文件夹与文件目录操作函数介绍
- JAVA文件/文件夹操作实用函数
- 几个文件夹操作的函数
- Python中对文件、文件夹(文件操作函数)
- java 实现 文件操作工具集。包括文件、目录树的拷贝、删除、移动、查找等工具函数
- php文件夹与文件目录操作函数介绍
- 如何利用系统函数操作文件夹及文件
- 文件夹操作函数及介绍
- GetCurrentDirectory等文件夹操作函数 && MessageBox信息函数 && VC应用执行DOS命令和批处理
- js 操作数组函数 (查找、删除 js中指定的数组元素)
- PB利用API-SHFileOperation 文件操作函数 实现多文件及文件夹的删除复制等操作
- asp下利用fso实现文件夹或文件移动改名等操作函数
- 操作注册表的API函数介绍(RegQueryValueEx:该函数用来查找一个给定类型和值的注册表项)
- 查找文件夹是否存在的函数。
- C语言学习5-1:字符加法,字符串操作函数编写,查找数组中第二大的数
- python中对文件、文件夹(文件操作函数)的操作 整理API