Hi everyone.
I'm making a media player using the BASS API Library and Direct-X.
My problem is, I'm using the FolderBrowserDialog component and I know it can't filter files but I need only files with specific extensions to be added to the Listbox I have on the form.
So far the code looks like this:
Public
Sub foldertoplaylist() Dim plug As Integer = 2 Dim playlistid3 As String Dim chosen As String Dim filInfo As IO.FileInfoAddFolder.Description =
"Choose the folder you would like to add to Tray-Play" If addfolder.ShowDialog = Windows.Forms.DialogResult.Cancel Then Exit Sub End Ifchosen = AddFolder.SelectedPath
Directory.GetDirectories(chosen)
Directory.GetFiles(chosen)
For Each fil1 As String In IO.Directory.GetFiles(AddFolder.SelectedPath)plug = Bass.BASS_StreamCreateFile(fil1, 0, 0, Un4seen.Bass.BASSStream.BASS_STREAM_DECODE)
filInfo =
New IO.FileInfo(fil1) Dim pluginfo As New Un4seen.Bass.AddOn.Tags.TAG_INFOBassTags.BASS_TAG_GetFromFile(plug, pluginfo)
playlistid3 = pluginfo.artist &
" - " & pluginfo.titleID3Artist = pluginfo.artist
ID3Title = pluginfo.title
ID3Album = pluginfo.album
If playlistid3 = " - " ThenListBox1.Items.Add(filInfo.Name)
ListBox2.Items.Add(filInfo.FullName)
ElseListBox1.Items.Add(playlistid3)
ListBox2.Items.Add(filInfo.FullName)
End Ifdefaultplaylist()
Next For Each dirgrab As String In IO.Directory.GetDirectories(AddFolder.SelectedPath) For Each fil2 As String In IO.Directory.GetFiles(dirgrab)plug = Bass.BASS_StreamCreateFile(fil2, 0, 0, Un4seen.Bass.BASSStream.BASS_STREAM_DECODE)
filInfo =
New IO.FileInfo(fil2) Dim pluginfo As New Un4seen.Bass.AddOn.Tags.TAG_INFOBassTags.BASS_TAG_GetFromFile(plug, pluginfo)
playlistid3 = pluginfo.artist &
" - " & pluginfo.titleID3Artist = pluginfo.artist
ID3Title = pluginfo.title
ID3Album = pluginfo.album
If playlistid3 = " - " ThenListBox1.Items.Add(filInfo.Name)
ListBox2.Items.Add(filInfo.FullName)
ElseListBox1.Items.Add(playlistid3)
ListBox2.Items.Add(filInfo.FullName)
End Ifdefaultplaylist()
Next Next End SubThat adds everything in the selected path folder and the sub folders (if any)
The problem is, its adds cover art (*.jpg, etc) to the list but all I want are the following extensions:
*.mod;*.mo3;*.s3m;*.xm;*.it;*.mtm;*.umx;*.mdz;*.s3z;*.itz;*.xmz;*.mp3;*.mp2;*.mp1;*.cda;*.wma;*.ogg;*.wav;*.aiff;*.ape;*.aac;*.m4a;*.flac;*.ams;*.avi;*.mpg;*.mpeg;*.wmv;*.mp4;*.asf;*.ogm;*.mkv;*.amp
Any ideas on how to filter for just the following formats from whats grabbed in the folders
thanks in advance.

Getting files with specific extensions using FolderBrowserDialog
TonyZhen
Your style still has a lot of VB6 influence. It was within the last year, almost exactly that I stopped coding in VB6. It's almost difficult to look at it now.
The methods included in the string class, are really powerful (although I wish there were a few more). I do still use Mid at times because is will do somethings that methods string methods won't.
But I byte my tongue when I do. ;)
Mr. Javaman
You're welcome. May I guess that you have a VB6 background
Richard Lennox
Here's a very short and sweet example:
OPNFD.Filter =
"Executable files (*.exe;*.cpl;*.bat)|*.exe;*.cpl;*.bat"OPNFD is the OpenFileDialogue... this is the syntax for the extension filter.
Opacki
Private Function GetExtension(ByVal Fname As String) As String
GetExtension = Nothing
Dim dotptr As Integer = Fname.LastIndexOf(".")
If dotptr = -1 Then Exit Function
GetExtension = Fname.Substring(dotptr + 1).ToLower
End Function
Maksim V.
GoldenBrown
Maybe I didn't explain myself very well. I'm trying to add a popular playlist function to my application, which is 'Add Folders to Playlist'.
So far I'm using the code I have posted above to grab files from the selected path of the Folder Browser Dialog and then to navigate through any sub folders (if present) to grab the files inside them also.
My only problem is that on adding folders it adds every file and I only need the specific set ones for audio/video, I don't want *.jpg, etc to be added to the list.
If there any way to just get the files with the specified extensions from the way I'm grabbing the information so that it misses out adding *jpg's, etc
Thanks in advance.
BimpnBerry
Took a wee bit of tweaking, but works brilliantly.
Kproject
Hope this helps a bit...
Larokas