文件夹的目录中号码 [英] Number of folder inside a directory

查看:83
本文介绍了文件夹的目录中号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么知道文件夹的数量的目录里面?

How do i know the number of folder inside a directory?

我尝试使用 System.IO.Directory ,但没有运气!

I try using System.IO.Directory but no luck!!

谢谢,
佩德罗

thanks, Pedro

推荐答案

您已经有了几个选项:

int directoryCount = System.IO.Directory.GetDirectories(@"c:\yourpath\").Length

var directoryInfo = new System.IO.DirectoryInfo(@"c:\yourpath\");
int directoryCount = directoryInfo.GetDirectories().Length;

如果你需要做其他的事情与他们,而你正在使用.NET 4中,可以使用DirectoryInfo.EnumerateDirectories()函数由于性能原因也是如此。

If you need to do other things with them, and you're using .NET 4, you can use the DirectoryInfo.EnumerateDirectories() function for performance reasons as well.

所以,是的,很多的选择。如果你仍然有问题,你可能想告诉我们没有使用System.IO.Directory时工作。

So yeah, lots of options. If you're still having problems, you might want to let us know what didn't work when using System.IO.Directory.

这篇关于文件夹的目录中号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆