Click here to Skip to main content
15,909,445 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
so i want to know how to select a folder, then i want my app to scan that folder for say any mp3 file in it and view the songs in a list.
i know how to select a path, i just want to know how can i make my app look for only mp3 files.
thanks
Posted

1 solution

Hi,
Well, all you have to do is use the GetFiles method in IO.Directory to get the path and matching extensions in that directory.
VB.NET:
VB
Function GetMatchingExtensions(ByVal Filter As String, ByVal Directory As String, ByVal SearchSubDirectories As Boolean) As String()
        If SearchSubDirectories Then
            Return IO.Directory.GetFiles(Directory, Filter, IO.SearchOption.AllDirectories)
        Else
            Return IO.Directory.GetFiles(Directory, Filter, IO.SearchOption.TopDirectoryOnly)
        End If
    End Function


Call upon this and list everything in listbox by:
VB
For Each file As String In GetMatchingExtensions("FILTER", "DIR", False)
            ListBox1.Items.Add(file)
        Next


Just convert this to C# if you want.
Regards,
iProgramIt
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900