新人求教:VB理如何统计文件个数?
请问:假设同一个文件下有a1.txt,a2.txt.....an.txt;b1.txt,b2.txt,.....bn.txt 五个txt文件,其中:a1.txt,a2.txt...an.txt为一类,b1.txt,b2.txt...bn.txt为一类;能用程序分别计算出各类文件的个数吗? --------------------编程问答-------------------- dim CountFileA as integer=0for each file as string in dlg.filenames
if file.chars(0)="a" then
CountFilea+=1
end if
--------------------编程问答-------------------- VB.NET 3.5
Dim files = Directory.GetFiles("路径", "*.txt", False)
Dim query = From x In files
Group x By key = x.Substring(0, 1) Into Group
Select Key = key, Count = Group.Count()
For Each g In query
Console.WriteLine(g)
Next
--------------------编程问答--------------------
LinQ ?學習了。。
补充:.NET技术 , VB.NET