On Sep 26, 6:45 am, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
wrote:
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
"kimiraikkonen" <kimiraikkone...@gmail.comschreef in berichtnews:11**********************@19g2000hsx.go oglegroups.com...
On Sep 26, 7:46 am, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl>
wrote:
Kimiraikkonen,
The folder browser is not to list files, it list the directories. The
normal
one for this is the OpenFileDialog.
Cor
"kimiraikkonen" <kimiraikkone...@gmail.comschreef in
berichtnews:11**********************@g4g2000hsf.go oglegroups.com...
Hello,
I have a listbox and folder browser control. I need to display
all .mp3 files' pathes into listbox.
It was Ok with openfiledialog but how can list all .mp3 extension-
having files into my listbox using folder browser control.
A sample code would be great.
Thanks...- Hide quoted text -
- Show quoted text -
Hello,
I want to see all .mp3 filenames in a listbox which are in a
directory, i mean i want to add dirrectory into a listbox to see their
filenames.
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