• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1332
  • Last Modified:

VB.Net:Get all files from a folder

Hi..
I use VB.Net, VS 2005

And I need some help getting all the files in a folder

I use a FolderBrowserDialog and when I have picked the folder ,I want to get all the files in that folder, or more correct I want to get all the files with the filepath to each file.

Any tips to do this?

Thx :)
0
AWestEng
Asked:
AWestEng
  • 2
  • 2
3 Solutions
 
tpwellsCommented:
System.IO.Directory.GetFiles(DirectoryPath)
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim fbd As New FolderBrowserDialog
        If fbd.ShowDialog = Windows.Forms.DialogResult.OK Then
            For Each fullFilePath As String In My.Computer.FileSystem.GetFiles(fbd.SelectedPath)
                Debug.Print(fullFilePath)
            Next
        End If
    End Sub
0
 
tpwellsCommented:
Hit Submit to soon. That call will get an array of strings of all the files in the directory
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
And one more...

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim fbd As New FolderBrowserDialog
        If fbd.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim di As New System.IO.DirectoryInfo(fbd.SelectedPath)
            For Each fi As System.IO.FileInfo In di.GetFiles()
                Debug.Print(fi.FullName)
            Next
        End If
    End Sub
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now