我想根据文件夹的大小对文件夹中的文件进行计数。例如,多少个文件小于512KB,多少个文件大于512KB。请帮助我。
答案 0 :(得分:1)
下面的子例程将帮助您获取计数
Sub GetFileDetails(ByVal sFolderPath As String, ByRef Filelessthan512KB As Integer, ByRef FileMorethan512KB As Integer)
Dim sFiles() As String = Directory.GetFiles(sFolderPath)
For Each file As String In sFiles
Dim oFileDetails As New FileInfo(file)
If (oFileDetails.Length / 1024) < 512 Then
Filelessthan512KB = Filelessthan512KB + 1
Else
FileMorethan512KB = FileMorethan512KB + 1
End If
Next
End Sub