vb.netç¼ç¨æ¥æ¾æç´¢æå®ç®å½ä¸é¢çæææ件åå
¶åç®å½ä¸çæ件ï¼æ¹æ³å¦ä¸ï¼
''=============================================
''å称: FindPath
''ä½ç¨: æ¥æ¾æç´¢æå®ç®å½ä¸é¢çæææ件åå
¶åç®å½ä¸çæ件
''åæ°ï¼strPath è¦æ¥æ¾çç®å½ï¼
''strFiles ç¨äºåæ¥æ¾ç»æçç¼å²åºï¼String ç±»åçå¨ææ°ç»ï¼è°ç¨æ¶äºå
åå§åï¼ å¦Redim strFiles(0)
''FileCount ç¨äºè¿åæ件个æ°
''=============================================
Public Sub FindPath(ByVal strPath As String, strFiles() As String, FileCount As Long)
Dim strDirs() As String
Dim strResult As String
Dim FileLimit As Long
Dim dirLimit As Long
Dim dirCount As Long
Dim I As Long
FileLimit = UBound(strFiles) + 1
dirLimit = 0
If Right$(strPath, 1) <> "/" Then strPath = strPath & "/"
strResult = Dir(strPath, vbDirectory + vbSystem + vbReadOnly + vbHidden + vbNormal + vbArchive)
Do While Len(strResult) > 0
If strResult <> "." And strResult <> ".." Then
If (GetAttr(strPath & strResult) And vbDirectory) <> vbDirectory Then
If FileCount >= FileLimit Then
ReDim Preserve strFiles(FileLimit + 10)
FileLimit = FileLimit + 10
End If
strFiles(FileCount) = strPath & strResult
FileCount = FileCount + 1
Else
If dirCount >= dirLimit Then
ReDim Preserve strDirs(dirLimit + 10)
dirLimit = dirLimit + 10
End If
strDirs(dirCount) = strPath & strResult
dirCount = dirCount + 1
End If
End If
strResult = Dir(, vbDirectory + vbSystem + vbReadOnly + vbHidden + vbNormal + vbArchive)
Loop
For I = 0 To dirCount - 1
Call FindPath(strDirs(I), strFiles, FileCount)
Next I
End Sub