The FolderBrowserDialog control lets us select a directory at run time instead of hard coding in a folder such as "c:/mypictures".
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Text = FolderBrowserDialog1.SelectedPath
Dim Folder As String = FolderBrowserDialog1.SelectedPath & "/"
Dim S As String
S = Dir(Folder) 'get first file from Selected Folder
While S <> ""
S = Dir() 'get next file in same directory
When you run the program the browser dialog opens
After selecting a folder, you will see a list of all the files in the folder you selected:
We display the selected path in the text. Notice that the text does not include a / at the end. We had to add a slash at the end in order for the Dir command to work:
Dim Folder As String = FolderBrowserDialog1.SelectedPath & "/"Next: Display the picture