473,395 Members | 1,460 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to list ALL filtered filenames (with path) from Folder Browser control?

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...

Sep 26 '07 #1
6 3136
Kimiraikkonen,

The folder browser is not to list files, it list the directories. The normal
one for this is the OpenFileDialog.

Cor

"kimiraikkonen" <ki*************@gmail.comschreef in bericht
news:11**********************@g4g2000hsf.googlegro ups.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...
Sep 26 '07 #2
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.

Sep 26 '07 #3
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" <ki*************@gmail.comschreef in bericht
news:11**********************@19g2000hsx.googlegro ups.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.g ooglegroups.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.

Sep 26 '07 #4
On Sep 26, 1:45 pm, "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.- Hide quoted text -

- Show quoted text -
If so, would you send me the whole code which allows me to retrieve
all the files' names into text boxes from a entire folder.

Sep 26 '07 #5
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

Sep 26 '07 #6
"kimiraikkonen" <ki*************@gmail.comschrieb
If so, would you send me the whole code which allows me to retrieve
all the files' names into text boxes from a entire folder.
Use System.IO.Directory.GetFiles or System.IO.DirectoryInfo.GetFiles. Press
F1 to get examples.
Armin

Sep 26 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: jamesthiele.usenet | last post by:
I wrote this little piece of code to get a list of relative paths of all files in or below the current directory (*NIX): walkList = , x) for x in os.walk(".")] filenames = for dir, files in...
2
by: djharrison | last post by:
I have managed to populate a dropdown box with a list of all files in the current folder and even filtered them by the extension so that it only displays the .mdb files. However, the menu seems to...
7
by: Dave Navarro | last post by:
I have a folder on the server with several thousand image files in it. I am using the following code to retrieve the image names associated with a given MLS number (this is for a real estate web...
5
by: Segfahlt | last post by:
I need a little help here please. I have 2 win forms user controls in 2 different projects that I'm hosting in 2 different virtual directories. The controls have been test and operate okay in...
22
by: rtilley | last post by:
# Spaces are present before and after the XXX filename = ' XXX ' new_filename = filename.strip() if new_filename != filename: print filename Macs allow these spaces in file and folder...
4
by: thoseion | last post by:
Hi, I am trying to get a program working whereby directory and file names are read into a list. I have been given the original list structure - it appears that the directory names should be added...
0
by: chongming | last post by:
Hi, i want to display all the filenames on browser. However i found that if there are many filenames in that folder, result will be it will display a long list of filenames on that browser. My...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: List of autostart locations Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list all the autostart locations for windows? Ans: Here is...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.