读书人

遍历目录文件的有关问题

发布时间: 2012-01-22 22:38:43 作者: rapoo

遍历目录文件的问题?
CFileFind的两个成员函数的区别:

MSDN
IsDirectory():
Determines if the found file is a directory.
IsDots()
Determines if the name of the found file has the name ". " or ".. ", indicating that is actually a directory.

都是目录??

if(ff.IsDirectory()) && !ff.IsDots())//只使用其中之一可否?
{
//如果是一个子目录,用递归继续往深一层找
SearchFile(ff.GetFilePath(),strFile);
}


bcb
if(sr.Attr==faDirectory && sr.Name!= ". " && sr.Name!= ".. ") //不搜索. 和 ..
. 和..表示什么意思?

[解决办法]
“.”为本目录
“..”为父目录
[解决办法]
if(ff.IsDirectory()) && !ff.IsDots())//只使用其中之一可否?
不可,一个是判断是否为目录,一个是判断是否为“.”和“..”目录

“.”和“..”是每个目录下必有的,默认的隐藏的目录 ". "是本目录, ".. "是父目录

读书人网 >VC/MFC

热点推荐