473,398 Members | 2,188 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,398 software developers and data experts.

searching for files in VB.net

I want to search for all the mp3's on my hard drive, and put them in a
combo box, so I can click them and they will play in a player.

I figured putting them in an array would work so that I could
correspond the name of the song with an alias of some sort, then have
just have the alias displayed. But I am unsure of how I can set up a
search to find the mp3 files.

any help would be nice

Ryan
Jul 21 '05 #1
7 29223
You can declare a Directoryinfo instance like

Dim di as New DirectoryInfo("C:\Whereeveryouwanttolook")

Dim fi as New FileInfo

for each fi in di.GetFiles
combobox.Items.Add(fi.Fullname)'Or whatever
next
"Ryan" <rm******@efni.com> wrote in message
news:8c**************************@posting.google.c om...
I want to search for all the mp3's on my hard drive, and put them in a
combo box, so I can click them and they will play in a player.

I figured putting them in an array would work so that I could
correspond the name of the song with an alias of some sort, then have
just have the alias displayed. But I am unsure of how I can set up a
search to find the mp3 files.

any help would be nice

Ryan

Jul 21 '05 #2
Will this work if the files are MP3's? or does it just take the name
of the file no matter what the type?

Also could there be a search done for all MP3's on the system? I ask
this because I want to know if different types of files can be found,
not just '.txt' files. And I do not want to manually type them in

Thanks

Ryan

"William Ryan" <do********@comcast.nospam.net> wrote in message news:<#q**************@TK2MSFTNGP09.phx.gbl>...
You can declare a Directoryinfo instance like

Dim di as New DirectoryInfo("C:\Whereeveryouwanttolook")

Dim fi as New FileInfo

for each fi in di.GetFiles
combobox.Items.Add(fi.Fullname)'Or whatever
next
"Ryan" <rm******@efni.com> wrote in message
news:8c**************************@posting.google.c om...
I want to search for all the mp3's on my hard drive, and put them in a
combo box, so I can click them and they will play in a player.

I figured putting them in an array would work so that I could
correspond the name of the song with an alias of some sort, then have
just have the alias displayed. But I am unsure of how I can set up a
search to find the mp3 files.

any help would be nice

Ryan

Jul 21 '05 #3
rm******@efni.com (Ryan) wrote in
news:8c**************************@posting.google.c om:
Will this work if the files are MP3's? or does it just take the name
of the file no matter what the type?


You'll have to test for the extension:

Dim di as New DirectoryInfo("C:\Whereeveryouwanttolook")

Dim fi as New FileInfo

for each fi in di.GetFiles
If Path.GetExtension(fi.FullName).ToUpper = ".MP3" Then
combobox.Items.Add(fi.Fullname)'Or whatever
End If
next
Jul 21 '05 #4
With Deft Fingers, rm******@efni.com (Ryan) wrote:
I want to search for all the mp3's on my hard drive, and put them in a
combo box, so I can click them and they will play in a player.
I used this Code to search for files with an extension of CTB. My "CTBFilPth"
was (in my case) the start folder. For example:

Dim CTBFilPth As String ' CTB Plot Style Files Path
CTBFilPth = "C:\Program Files\AutoCAD LT 2002\Plot Styles\"

So take this and play with it. It will search sub-folders too... When it
finds a CTB file, it adds it to a Combox (cmbCTB):

' Find Plot Styles in Multiple Folders and Lists them
' Get Folder Names Listing in Plot Styles Path
Dim rootDi As New DirectoryInfo(CTBFilPth)
Dim di As DirectoryInfo
For Each di In rootDi.GetDirectories
Dim CTBdirs() As String = Directory.GetFiles(CTBFilPth & di.Name)
For Each CTBfilname In CTBdirs
CTBtestname = System.IO.Path.GetFileName(CTBfilname)
' Test for CTB files and add to Combox 'cmbCTB'
Dim FilTest As String = CTBtestname.Remove(0, (Len(CTBtestname) - 3))
If UCase(FilTest) = "CTB" Then
cmbCTB.Items.Add(CTBtestname)
End If
Next
Next
I figured putting them in an array would work so that I could
correspond the name of the song with an alias of some sort, then have


You don't have to use an Array... you can select right off the Combox.

Regards,

Bruce
Jul 21 '05 #5
Mr. B <Us**@NoWhere.Com> wrote in message news:<6v********************************@4ax.com>. ..
With Deft Fingers, rm******@efni.com (Ryan) wrote:
I want to search for all the mp3's on my hard drive, and put them in a
combo box, so I can click them and they will play in a player.


I used this Code to search for files with an extension of CTB. My "CTBFilPth"
was (in my case) the start folder. For example:

Dim CTBFilPth As String ' CTB Plot Style Files Path
CTBFilPth = "C:\Program Files\AutoCAD LT 2002\Plot Styles\"

So take this and play with it. It will search sub-folders too... When it
finds a CTB file, it adds it to a Combox (cmbCTB):

' Find Plot Styles in Multiple Folders and Lists them
' Get Folder Names Listing in Plot Styles Path
Dim rootDi As New DirectoryInfo(CTBFilPth)
Dim di As DirectoryInfo
For Each di In rootDi.GetDirectories
Dim CTBdirs() As String = Directory.GetFiles(CTBFilPth & di.Name)
For Each CTBfilname In CTBdirs
CTBtestname = System.IO.Path.GetFileName(CTBfilname)
' Test for CTB files and add to Combox 'cmbCTB'
Dim FilTest As String = CTBtestname.Remove(0, (Len(CTBtestname) - 3))
If UCase(FilTest) = "CTB" Then
cmbCTB.Items.Add(CTBtestname)
End If
Next
Next
I figured putting them in an array would work so that I could
correspond the name of the song with an alias of some sort, then have


You don't have to use an Array... you can select right off the Combox.

Regards,

Bruce


I want to know... is DirectoryInfo a class that I have to create
myself or is it predefined in VB.Net? Everytime that I try and use it,
VB.Net tells me that it needs to be defined. Could someone please
explain this to me

Thank You

Ryan
Jul 21 '05 #6
Mr. B <Us**@NoWhere.Com> wrote in message news:<6v********************************@4ax.com>. ..
With Deft Fingers, rm******@efni.com (Ryan) wrote:
I want to search for all the mp3's on my hard drive, and put them in a
combo box, so I can click them and they will play in a player.


I used this Code to search for files with an extension of CTB. My "CTBFilPth"
was (in my case) the start folder. For example:

Dim CTBFilPth As String ' CTB Plot Style Files Path
CTBFilPth = "C:\Program Files\AutoCAD LT 2002\Plot Styles\"

So take this and play with it. It will search sub-folders too... When it
finds a CTB file, it adds it to a Combox (cmbCTB):

' Find Plot Styles in Multiple Folders and Lists them
' Get Folder Names Listing in Plot Styles Path
Dim rootDi As New DirectoryInfo(CTBFilPth)
Dim di As DirectoryInfo
For Each di In rootDi.GetDirectories
Dim CTBdirs() As String = Directory.GetFiles(CTBFilPth & di.Name)
For Each CTBfilname In CTBdirs
CTBtestname = System.IO.Path.GetFileName(CTBfilname)
' Test for CTB files and add to Combox 'cmbCTB'
Dim FilTest As String = CTBtestname.Remove(0, (Len(CTBtestname) - 3))
If UCase(FilTest) = "CTB" Then
cmbCTB.Items.Add(CTBtestname)
End If
Next
Next
I figured putting them in an array would work so that I could
correspond the name of the song with an alias of some sort, then have


You don't have to use an Array... you can select right off the Combox.

Regards,

Bruce


PLease disregard the last message that was posted...I forgot to import
the systems.IO and system name spaces

Ryan
Jul 21 '05 #7
With Deft Fingers, rm******@efni.com (Ryan) wrote:
PLease disregard the last message that was posted...I forgot to import
the systems.IO and system name spaces


Oops... sorry about not mentioning it (:

Bruce
Jul 21 '05 #8

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

Similar topics

2
by: John | last post by:
Hi everyone ! This is a first time I post a message here. If I post my message in a wrong group. Please ignore it. I am trying to build a website which allows users (can be thousands of...
4
by: ADE | last post by:
Hi I was wondering if one of you could help me out I would like for this function to be able to find file names as well instead of printing out every file that ends with a .jpg or .gif extension...
3
by: Ma Xiaoming | last post by:
Dear ladies and gentlemen, As you know, by building a Smart Device Application in Microsoft Visual Studio .NET 2003, we could create a project for Pocket PC. My question is: How to search...
2
by: Paul Bromley | last post by:
Can someone give me a pointer of the best way to show that an application is busy and has not locked up? I am writing a utility to search a network drive for a number of tiff files. I will...
29
by: jaysherby | last post by:
I'm new at Python and I need a little advice. Part of the script I'm trying to write needs to be aware of all the files of a certain extension in the script's path and all sub-directories. Can...
1
by: Christian Münscher | last post by:
Hi Group! Here I have a big chaotic web-project where all 500 files are lying around in on directory without any structure. On the content-level there is a structure, the whole thing is divided...
5
by: bir | last post by:
I have a folder which contains the xml files with the word CICM in the filename (can also contain some other files) I need to search for all these xml files and create a single zip file for all...
11
by: jonathan184 | last post by:
script to search for keywords in files in a dir Basically the script consists of a file with part numbers I got a dir with files I want to search the files line by line and if a line has the...
1
by: SSJVEGETA | last post by:
Hello, everybody. I have read some examples and manuals for the egrep command for Linux and I don't know if this egrep command is right for the particular files I am searching for. Here is what the...
6
by: bushwacker | last post by:
Hello all, I'm a chemical engineering student. our teacher has given us a project to do some calculations based on some equations. those equations include constants, which are to be read from a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.