OK so I have some code which gets the title and artist from the ID3 tag of an mp3 file.
Now the problem is, in order for these to properly show up in my listview, I have to pass them through a textbox first.
Heres my code:
If I do not pass the strings through the textbox, they do not show up properly in the listview. Why is this happening?Code:For Each filePath As String In IO.Directory.GetFiles(DirListBox1.Path, "*.mp3", IO.SearchOption.AllDirectories) Dim title As String = "" Dim artist As String = "" Dim buffer(128) As Byte Dim mp3File As New FileInfo(filePath) If mp3File.Length > 128 Then Dim i As Integer Dim mp3Reader As Stream = mp3File.OpenRead() mp3Reader.Seek(-128, SeekOrigin.End) For i = 0 To 127 buffer(i) = mp3Reader.ReadByte Next mp3Reader.Close() End If If Encoding.Default.GetString(buffer, 0, 3).Equals("TAG") Then title = Trim(Encoding.Default.GetString(buffer, 3, 30)) artist = Trim(Encoding.Default.GetString(buffer, 33, 30)) End If TextBox1.Text = title TextBox2.Text = artist fMain.ListView1.Items.Add(TextBox2.Text + " - " + TextBox1.Text).SubItems.Add(filePath) Next




Reply With Quote