列目录

     Sub Find(ByVal i As Int64, ByVal dirpath As String)

        Try
            Dim path As New DirectoryInfo(dirpath)
            For Each f As FileInfo In path.GetFiles()
                Console.WriteLine(Space(i * 4) & f.Name)
                fnum += 1
            Next
            For Each p As DirectoryInfo In path.GetDirectories()
                Console.WriteLine(Space(i * 4) & p.Name)
                pnum += 1
                Find(i + 1, p.FullName)
 
            Next
        Catch ex As Exception
            ‘ Eat it.
        End Try
    End Sub
使用: Find(0, 根目录)
例如: Find(0, "C:\")

 

发表评论

注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

:wink: :twisted: :roll: :oops: :mrgreen: :lol: :idea: :evil: :cry: :arrow: :?: :-| :-x :-o :-P :-D :-? :) :( :!: 8-O 8)

本文链接:https://twd2.me/archives/287QrCode