void FileSysManager::DeleteDirectory(TFileName fn)
{
CDir* _pDir = NULL;
iSessionRFs.GetDir(fn,KEntryAttMaskSupported,ESortByName,_pDir);
if( !_pDir )
{
return;
}
for(TInt i=0;i<_pDir->Count();i++)
{
TFileName tmp;
tmp.Append(fn);
if((*_pDir)[i].IsDir())
{
tmp.Append((*_pDir)[i].iName);
tmp.Append(_L("\\"));
DeleteDirectory(tmp);
iSessionRFs.RmDir(tmp);
}
else
{
tmp.Append((*_pDir)[i].iName);
iSessionRFs.Delete(tmp);
}
}
delete _pDir;
}
上面的代码经测试可以正确删除任意文件或文件夹,可以放心使用
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9059159/viewspace-588938/
,如需转载,请注明出处,否则将追究法律责任。