'获取指定目录下的所有文件名(包括子目录)(使用了递归调用)
Private Function DynamicList(ByVal strParentDir As String) As String()
Dim strSubDir() As String
Dim strSubFile() As String
Dim strSubSubFile() As String
If Tools.IsFileExist(strParentDir) Then
ReDim strSubFile(0)
strSubFile(0) = strParentDir
Else
Dim objDir As Directory
Dim I As Integer = 0
Try
strSubDir = objDir.GetDirectories(strParentDir)
strSubFile = objDir.GetFiles(strParentDir)
If Not IsNothing(strSubDir) Then
For I = 0 To strSubDir.Length - 1
strSubSubFile = DynamicList(strSubDir(I))
If Not IsNothing(strSubSubFile) Then Tools.UniteStrArrayA(strSubFile, strSubSubFile)
Next
End If
Catch e As Exception
AddSysLog("取要备份的文件列表时发生错误:" & e.Message & "(" & strParentDir & ")", EventLogEntryType.Error, 101)
strSubFile = Nothing
Finally
strSubDir = Nothing
strSubSubFile = Nothing
objDir = Nothing
End Try
End If
Return strSubFile
End Function