To: aqua_aqua(丁丁) 函数名应该是 findfirst() 和 findnext(),没有下滑线_(Help 里有下滑线, 但实际上没有下滑线)。另外,没有C里没有 findclose() 函数。
这我到没找,只知道它是包含在io.h中的。你可以用F11跟进去看一下。
有的。是有下滑线的。也有_findclose()这个函数。要不要我把那页MSDN贴出来。
_findclose Closes the specified search handle and releases associated resources.int _findclose( long handle );Function Required Header Compatibility _findclose <io.h> Win 95, Win NT For additional compatibility information, see Compatibility in the Introduction.LibrariesLIBC.LIB Single thread static library, retail version LIBCMT.LIB Multithread static library, retail version MSVCRT.LIB Import library for MSVCRT.DLL, retail version Return ValueIf successful, _findclose returns 0. Otherwise, it returns –1 and sets errno to ENOENT, indicating that no more matching files could be found.ParameterhandleSearch handle returned by a previous call to _findfirstSystem Calls Routines | _find, _wfind Function Overview -------------------------------------------------------------------------------- Send feedback to MSDN.Look here for MSDN Online resources.
_finddata_t fblk;
long handle,result;
char child[_MAX_PATH];
child = "c:\\web\\*.htm";
result = handle = _findfirst(child,&fblk);while(result !=-1)
{
if(((fblk.attrib&_A_SUBDIR)!=0)&&strcmp(fblk.name,".")&&strcmp
(fblk.name,".."))
{你想于什么就在这干吧。
}
result = _findnext(handle,&fblk);
}
_findlclose(handle);
}
例如:
strPath = "c:\web\";
strExtMask = "*.htm";
void GetFileList(CString strPath, CString strExtMask)
{
CFileFind finder;
CString strNewPth;//可以得到你想要的文件的路径
BOOL bWorking = finder.FindFile(strPath + strExtMask); while (bWorking)
{
bWorking = finder.FindNextFile();
//忽略 .和 ..文件; 否则就
//死循环了!
if (finder.IsDots())
continue;
//如果是目录,递归搜索
if (finder.IsDirectory())
{
strNewPath = finder.GetFilePath();
strNewPath += "\\";
strNewPath += strExtMask;
}
else
{
strNewPath = finder.GetFilePath();
}
}
finder.Close();
}
(fblk.name,".."))
//这句不好理解哦,可以写清楚一点么?谢了先 :)
谢谢! :)
你的代码非常好,但CFileFind类是MFC的啊
能有更底层的吗?
了解了,谢谢 ! :)
(fblk.name,".."))
fblk.attrib&_A_SUBDIR 是代表这个目录下的子目录,
同时在每个目录下都有两个系统自动生成的文件。这两个文件的文件名就是"."和"..",所以要去掉。
唉呀,其这个条件语句没有也行了。我这是从原来的文件中截下来的。
能找到_findnext(..)这个函数的源代码吗?
它保存在什么地方?
函数名应该是 findfirst() 和 findnext(),没有下滑线_(Help 里有下滑线,
但实际上没有下滑线)。另外,没有C里没有 findclose() 函数。
Closes the specified search handle and releases associated resources.int _findclose( long handle );Function Required Header Compatibility
_findclose <io.h> Win 95, Win NT
For additional compatibility information, see Compatibility in the Introduction.LibrariesLIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version
Return ValueIf successful, _findclose returns 0. Otherwise, it returns –1 and sets errno to ENOENT, indicating that no more matching files could be found.ParameterhandleSearch handle returned by a previous call to _findfirstSystem Calls Routines | _find, _wfind Function Overview
--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.