遍历文件夹windows

来源:互联网 发布:类似youcam的软件 编辑:程序博客网 时间:2024/05/22 16:58

写这篇博客主要是深化一下记忆,就是搜索字符串

1、C:\bbb  就是搜索这个文件存在搜索到,不存在,出错

2、C:\bbb\*搜索C:\bbb目录下的所有文件

3、C:\bbb\不正确搜索格式

遍历方式:

_finddata_t fileInfo;long handle;CString localDir="";handle=_findfirst((LPCTSTR)(localDir),&fileInfo);if (handle==-1){return false;}else{do {if (fileInfo.attrib&_A_SUBDIR){if (!strcmp(fileInfo.name,".")||!strcmp(fileInfo.name,"..")){continue;}}else{}} while(_findnext(handle, &fileInfo) == 0);}_findclose(handle);return true;