Link to home
Start Free TrialLog in
Avatar of XK8ER
XK8ERFlag for United States of America

asked on

vb.net - sub directories issue

hello there,
I have about 3500 files, all in sub directories.
I am trying to get the full path for each of the files but this code only shows about 235 files and it wont show the full path.
how can I get the full path for all 3,500 files?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        lvCount.Text = 0
        If txtPath.Text <> "" Then
            Call leGetFiles(txtPath.Text)
        Else
            Debug.Print("You need to specify a directory")
        End If
    End Sub

    Private Sub leGetFiles(ByVal strDir As String)
        Dim qFiles = IO.Directory.GetDirectories(strDir)
        Dim xFiles = IO.Directory.GetFiles(strDir)
        For Each strFile In xFiles
            Debug.Print(strFile)
            lvCount.Text = Val(lvCount.Text) + 1
        Next
        Dim qDirs = IO.Directory.GetDirectories(strDir)
        For Each y In qDirs
            Dim subFiles = IO.Directory.GetFiles(IO.Path.Combine(strDir, y))
            For Each strFile In qFiles
                Debug.Print(strFile)
                lvCount.Text = Val(lvCount.Text) + 1
            Next
        Next
    End Sub

Open in new window

Avatar of nepaluz
nepaluz
Flag of United Kingdom of Great Britain and Northern Ireland image

you will get the full paths for the Debug.Print with this
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        lvCount.Text = 0
        If txtPath.Text <> "" Then
            Call leGetFiles(txtPath.Text)
        Else
            Debug.Print("You need to specify a directory")
        End If
    End Sub

    Private Sub leGetFiles(ByVal strDir As String)
        Dim qFiles = IO.Directory.GetDirectories(strDir)
        Dim xFiles = IO.Directory.GetFiles(strDir)
        For Each strFile In xFiles
            Debug.Print(Path.Combine(strDir, strFile))
            lvCount.Text = Val(lvCount.Text) + 1
        Next
        Dim qDirs = IO.Directory.GetDirectories(strDir)
        For Each y In qDirs
            Dim subFiles = IO.Directory.GetFiles(IO.Path.Combine(strDir, y))
            For Each strFile In qFiles
                Debug.Print(Path.Combine(IO.Path.Combine(strDir, y), strFile))
                lvCount.Text = Val(lvCount.Text) + 1
            Next
        Next
    End Sub

Open in new window

Avatar of XK8ER

ASKER

its not working because its showing 235 files only
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you must have sub directories within the sub directories. If this is the case and you want to include these as well, what is the depth of your search? i.e how deep is the directory structure?
Avatar of XK8ER

ASKER

about 8 sud dirs