Domanda

I am developing an application to find, play and display all media, but primarily music. I am using Visual Studio 2012 in vb.net. On my form I have a Windows Media Player (WMP) and two listviews. The first listview (lvFolders) displays all folders of drive location. When I select a folder it automatically loads all files (media tracks) into the second listview (lvPlaylist), and starts playing the first track using the WMP. That all works well.

In each of these folders (500+) I have a cover of the respective album named "front.bmp". I cannot for the life of me work out what I am doing wrong. As the listview is populating the folders I am trying for it to load each image file located within that folder into the imagelist, and display the folders as large icons using that image. The result would be 500+ large folders each displaying their respective album cover from the imagelist.

I specifically didn't want to use Folder Browser Dialog or Open File Dialog. This application is for a touch based application for my own personal use.

I have attached my code in case it helps understand my dilemma.

    Private Sub LoadFolders_Click(sender As Object, e As EventArgs) Handles btnLoadFolders.Click

    For Each strDir As String In My.Computer.FileSystem.GetDirectories("E:\Music\TEST")


        Dim imageListLarge As New ImageList()
        Dim strAlbumArt As String = strDir & "\" & (My.Computer.FileSystem.GetName(strDir)) & ".bmp"        'URL of the image
        imageListLarge.ColorDepth = ColorDepth.Depth32Bit                                                   'Set the colour
        imageListLarge.ImageSize = New Size(128, 128)                                                       'Set image size
        imageListLarge.Images.Add(strAlbumArt, Image.FromFile(strAlbumArt))                                 'Add image to image list
        lvFolders.LargeImageList = imageListLarge                                                           'Assign the imagelist to the listview

        Dim NewItem As New ListViewItem(My.Computer.FileSystem.GetName(strDir), strAlbumArt)                'Create Column 1 data
        NewItem.SubItems.Add(My.Computer.FileSystem.GetFileInfo(strDir).FullName)                           'Create Column 2 data

        lvFolders.Items.Add(NewItem)                                                                        'Load into listview

    Next

End Sub
È stato utile?

Soluzione

Dim strAlbumArt As String = strDir & "\" & (My.Computer.FileSystem.GetName(strDir)) & ".bmp"

doesn't have "front.bmp" in it. Are you sure you don't mean something like Dim strAlbumArt As String = strDir & "\front.bmp?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top