Why you want a folderbrowser while the openfiledialog with a filter does
that direct?
I cannot give you a link, MSDN seems to be unavailable.
However you can search for that later.
http://msdn2.microsoft.com/en-us/default.aspx
Cor
Cor, I believe the OP is not trying to build a file picker, but is
trying to find the files for an MP3 player based on other posts I've
responded to by the OP.
To the OP:
Here is some code that will search a path and subpaths for any .mp3
files and load them into the listbox I showed you in an earlier post.
Be warned, this is very slow and probably should be set up to run
asynchronously, and will die if it hits any directories it does not
have permission to access. These are two issues you need to solve on
your own.
To use this code create a new windows form application and add a
listbox to Form1. Then replace the code-behind with the following
code:
//////////////////////
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
LoadFiles()
End Sub
Private Sub LoadFiles()
Dim files As String() = Directory.GetFiles("C:\", "*.mp3",
SearchOption.AllDirectories)
For Each file As String In files
Me.ListBox1.Items.Add(New
FileInformation(Path.GetFileName(file), file))
Next
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ListBox1.SelectedIndexChanged
Try
Dim item As FileInformation =
DirectCast(Me.ListBox1.SelectedItem, FileInformation)
MsgBox(String.Format("The path for item '{0}' is '{1}'",
item.FileName, item.FilePath), MsgBoxStyle.OkOnly, "File Information")
Catch ex As InvalidCastException
MsgBox("The selected file was not found.")
'// Remove the item to prevent further troubles
Me.ListBox1.Items.Remove(Me.ListBox1.SelectedItem)
End Try
End Sub
End Class
Public Class FileInformation
Public Sub New()
End Sub
Public Sub New(ByVal fileName As String, ByVal filePath As String)
Me.FileName = fileName
Me.FilePath = filePath
End Sub
Public Property FileName() As String
Get
Return _FileName
End Get
Set(ByVal value As String)
_FileName = value
End Set
End Property
Private _FileName As String = String.Empty
Public Property FilePath() As String
Get
Return _FilePath
End Get
Set(ByVal value As String)
_FilePath = value
End Set
End Property
Private _FilePath As String = String.Empty
Public Overrides Function ToString() As String
Return FileName
End Function
End Class
//////////////////////
Thanks,
Seth Rowe