By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,986 Members | 1,522 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,986 IT Pros & Developers. It's quick & easy.

Opening a file in VB

P: 5
This code should open an MP3 file into a list box:
Expand|Select|Wrap|Line Numbers
  1.  Private Sub btnAddFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddFile.Click
  2.         Dim OpenFile As New OpenFileDialog
  3.         Dim file As String
  5.         OpenFile.InitialDirectory = "C:\Documents and Settings\Matth\My Documents\test1\"
  6.         OpenFile.Filter = "MP3 Files (*.mp3)|*.MP3"
  7.         OpenFile.RestoreDirectory = True
  8.         OpenFile.Multiselect = True
  9.         If OpenFile.ShowDialog() = Windows.Forms.DialogResult.OK Then
  10.             For Each file In OpenFile.FileNames
  11.                 Dim sread As New IO.StreamReader(file), s As String() = sread.ReadToEnd().Split(Chr(10))
  12.                 For Each str As String In s
  13.                     FileList.Items.Add(str)
  14.                 Next
  15.             Next
  16.         End If
  17.     End Sub
Unfortunately, it doesn't open the file in the list box as a '.mp3' file, but it just outputs 'A Music File{}'

could someone help please???
Dec 4 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.