About Chris Expertise I can answer pretty much any question relating to VB.NET and its use in a Windows environment. I specialize in ASP.NET web development and MSSQL database access.
Experience I have over 5 years of industry experience using VB.NET and other .NET technologies for web and database development.
Education/Credentials I have some college education, but does it really matter in this field of work?
Expert: Chris Date: 8/17/2007 Subject: List box and open file dialog issues
Question Dear Sir,
I'm working on an ID3 tag editor for .mp3 files. One of my options is to change the file name (eg. "bandname-track number-songtitle.mp3" to "songtitle.mp3")
I wish to set this up by clinking a button which opens a 'open file dialog'. The dialog has been set to select multiple files, however when i accept it the list box only shows up the first file i select. my code is:
Private Sub btnFolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFolder.Click
Dim Ofiles As String
FolderOpen.InitialDirectory = "C:\Users\Steve\Music"
FolderOpen.Multiselect = True
FolderOpen.Title = "Choose .Mp3's To Re-Tag"
FolderOpen.Filter = "Mpeg Audio Files| *.mp3"
FolderOpen.ShowDialog()
Ofiles = FolderOpen.FileName
LstList.Items.Add(Ofiles)
End Sub
i have tried to change "Ofiles = folderOpen.fileName" to end with FolderOpen.filenames but when i add the 's' it comes up with errors.
Any help would be greatly appreciated. Also, Last time I asked a question from you I had a great response and it helped me greatly so I thank you for that.
I may have 1 or 2 more questions too.
Thankyou for your time
Steve.
Answer Hi,
You've got a really simple to answer question here... You can use the .FileNames property of the OpenFileDialog control, which is an array of strings, each holding a file name that was selected.
Private Sub btnFolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFolder.Click
FolderOpen.InitialDirectory = "C:\Users\Steve\Music"
FolderOpen.Multiselect = True
FolderOpen.Title = "Choose .Mp3's To Re-Tag"
FolderOpen.Filter = "Mpeg Audio Files| *.mp3"
' Make sure the User clicked OK and not Cancel
If (FolderOpen.ShowDialog() = Windows.Forms.DialogResult.OK) Then
' Make sure the User selected one or more files
If (FolderOpen.FileNames.Length > 0) Then
' Loop through the list of selected filenames and add each one to your listbox
For Each strFileName As String In FolderOpen.FileNames
LstList.Items.Add(strFileName)
Next
End If
End If
End Sub
Sounds like a very interesting project you're working on there, let me know if there's anything else you need help with.