如何使用c#.net获取目录中文件的数量 [英] How to get count of files in a directory using c#.net
本文介绍了如何使用c#.net获取目录中文件的数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我想获取目录中文件的数量,例如gmail,您可以引导或发送任何代码段
Hello,
I want get count of my files in a directory as like gmail can u guide or send any snippets
推荐答案
int fileCount = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).Length; // Will Retrieve count of all files in directry and sub directries
int fileCount = Directory.GetFiles(path, "*.*", SearchOption.TopDirectory).Length; // Will Retrieve count of all files in directry but not sub directries
int fileCount = Directory.GetFiles(path, "*.xml", SearchOption.AllDirectories).Length; // Will Retrieve count of files XML extension in directry and sub directries
或在这里查看:
http://social.msdn.microsoft.com/论坛/en-US/Vsexpressvcs/thread/3ea19b83-b831-4f30-9377-bc1588b94d23 [ http://pcheruku .wordpress.com/2008/09/03/c-code-to-recursively/ [
or see here:
http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/3ea19b83-b831-4f30-9377-bc1588b94d23[^]
http://pcheruku.wordpress.com/2008/09/03/c-code-to-get-the-file-count-in-a-directory-recursively/[^]
这篇关于如何使用c#.net获取目录中文件的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文