ASP.NET希望计算目录中的文件数

时间:2011-12-21 22:45:06

标签: asp.net

只是想知道如何计算扩展名为.txt的给定目录中的文件数?

由于

4 个答案:

答案 0 :(得分:6)

Directory.EnumerateFiles(path, "*.txt").Count()

答案 1 :(得分:1)

System.IO.Directory.GetFiles("Path", "*.txt").Count()

答案 2 :(得分:0)

var di = new DirectoryInfo(@"c:\");
var count = di.GetFiles("*.txt").Length;

答案 3 :(得分:0)

'Replace C:\ with your directory.
Dim intCount As Integer = (From s As String In System.IO.Directory.GetFiles("C:\") _
                           Where Microsoft.VisualBasic.Right(s, 4) = ".txt").Count