在我的代码中,我使用GetFiles()-method
来计算给定文件夹中的文件数
让我们假设以下文件夹结构:
FolderA
File1
File2
File3
FolderB
File4
File5
FolderC
File9
File10
FolderD
File6
File7
FolderE
File8
要确定文件计数,请使用以下代码:
Dim filename as String = 'Path to my FolderA: C:/....../Desktop/FolderA
Dim myFileCount as Integer = 0
myFileCount = Directory.GetFiles(filename, "*.*", SearchOption.AllDirectories).Length
Result: MyfileCount is 3 instead of 10
执行此代码时,FolderB
&的内容FolderC
不包括在内。在MSDN-Library - GetFiles()和MSDN-Library - SearchOption后,这应该有效.....
我做错了什么?
答案 0 :(得分:0)
尝试:
Directory.GetFiles(filename,"*.*",SearchOption.SearchAllSubDirectories).Length