vc如何获取文件夹中文件个数

vc如何获取文件夹中文件个数,第1张

递归获取本文件夹(包括子文件夹)中的文件:

int CountDirectory(CString path)

{

int count = 0;

CFileFind finder;

BOOL working = finderFindFile(path + "\\");

while (working)

{

working = finderFindNextFile();

if (finderIsDots())

continue;

if (finderIsDirectory())

count += CountDirectory(finderGetFilePath());

else

count++;

}

return count;

}

只获取本文件夹中的文件:

int CountDirectory(CString path)

{

int count = 0;

CFileFind finder;

BOOL working = finderFindFile(path + "\\");

while (working)

{

working = finderFindNextFile();

if (finderIsDots())

continue;

if (!finderIsDirectory())

count++;

}

return count;

}

用DOS的dir命令即可。如果只有一级目录,即下面不包含子目录,直接用dir即可,如下图,将显示共有多少个文件。

如果下面还包括子目录,可以加参数/s。如下图,即可以显示包括多少文件及多少目录。

$a = count(glob("",GLOB_ONLYDIR));

$b = count(glob(""));

echo '当前目录下文件夹数量:',$a,',文件数量:',$b-$a;

//这样就可以获取当前目录的文件夹和文件数量了

以上就是关于vc如何获取文件夹中文件个数全部的内容,包括:vc如何获取文件夹中文件个数、如何用DOS命令,获取一个目录下的文件数目、php中怎样获取目录中文件的个数等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9687786.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-30
下一篇2023-04-30

发表评论

登录后才能评论

评论列表(0条)

    保存