从一个文件夹中查找一个文件——递归

来源:互联网 发布:沙发推荐 实木 知乎 编辑:程序博客网 时间:2024/06/04 18:42
   Private Function GetBackUpFile(ByVal fileName As String, ByVal backupPath As String) As String        Try            Dim flg = False            Dim fileList = Directory.GetFileSystemEntries(backupPath)            For Each filePath In fileList                If Directory.Exists(filePath) Then                    Dim csvPath As String = GetBackUpFile(fileName, filePath)                    If csvPath IsNot Nothing Then                        Return csvPath                    End If                Else                    If Path.GetFileName(filePath) = fileName Then                        Return filePath                    End If                End If            Next            Return Nothing        Catch ex As Exception            Return Nothing        End Try    End Function

0 0
原创粉丝点击