[code=c]
struct _finddata_t p;
while(_findnext( hFile, &p ) == 0)
{
if(p.attrib==_A_SUBDIR)
{
char szPath[_MAX_PATH] = {NULL};
strcpy(szPath, path);
strcat(szPath, "\\");
strcat(szPath, p.name);
if ((_access(szPath,0))!=-1) {
DeleteTree(szPath);
rmdir(szPath);
}
}
else
{
char szPath[_MAX_PATH] = {NULL};
strcpy(szPath, path);
strcat(szPath, "\\");
strcat(szPath, p.name);
_unlink(szPath);
}
}[/
code]
以上代码p.name每次的值是:".."
然后下面红色部分 :(_access(szPath,0)) 路径检查的时候都会判断".."存在
例如 szPath="E:DataRec\2013-10-17\..\..\..\..\..\..\..\.."
会不止境的循环下去!!其实这个路径到“E:DataRec\2013-10-17”就没了
这个问题纠结很久了,不知道为嘛!!