计算给定路径中的所有文件和目录(包括子文件夹) [英] Counting all the files and directories including sub folders in a given path

查看:109
本文介绍了计算给定路径中的所有文件和目录(包括子文件夹)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我需要一个这样的函数,它以文件夹路径作为输入,并给出所有文件和文件夹(包括子文件夹)的编号作为输出.请尽快提供帮助....

Hello ALL,
I need a such function that take a folder path as input and gives the no of all files and folders including sub folders as output.Please help as soon as possible....

推荐答案

var path = @"L:\";
int files = System.IO.Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).Count();
int dirs = System.IO.Directory.GetDirectories(path, "*", SearchOption.AllDirectories).Count();


这篇关于计算给定路径中的所有文件和目录(包括子文件夹)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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