i want my listbox to show every file of a certain file type in a specified folder (audio files to be more specific)
how would i go about doing that?
thnx
Phil
Printable View
i want my listbox to show every file of a certain file type in a specified folder (audio files to be more specific)
how would i go about doing that?
thnx
Phil
I can't remember the format for the pattern searching so that bit is probably wrong but the code works perfectly. Just check out how to specify a search pattern:
VB Code:
Dim di As New IO.DirectoryInfo("Path here") Dim diArr As IO.FileInfo() = di.GetFiles("*.mp3") 'This gets certain type. I can't remember the format though For Each dri As IO.FileInfo In diArr listbox1.Items.Add(dri.Name) 'Add to listbox Next dri
sweet it works! thanks a bunch. is there a way so that it doesn't show the extension (.mp3)?
You can either process the items in the list and remove the extension or you can check out the:
IO.Path.GetFileNameWithoutExtension(String)
Method. The above code I posted wont work as is with this method however due to the new method using a string to function.
VB Code:
Dim tmp As String = "D:\My Documents\" Dim Files() As String Files = System.IO.Directory.GetFiles(tmp, "*.mp3") For Each str As String In Files ListBox1.Items.Add(IO.Path.GetFileNameWithoutExtension(str)) Next
kickass thanks a bunch