Vb.net 在Listview中,为每个项目(文件夹)分配一个来自每个文件夹的图像

Vb.net 在Listview中,为每个项目(文件夹)分配一个来自每个文件夹的图像,vb.net,listview,filesystems,windows-media-player,imagelist,Vb.net,Listview,Filesystems,Windows Media Player,Imagelist,我正在开发一个应用程序来查找、播放和显示所有媒体,但主要是音乐。我正在vb.net中使用Visual Studio 2012。在我的表单上,我有一个Windows Media Player(WMP)和两个列表视图。第一个列表视图(lvFolders)显示驱动器位置的所有文件夹。当我选择一个文件夹时,它会自动将所有文件(媒体曲目)加载到第二个listview(lvPlaylist)中,并开始使用WMP播放第一个曲目。这一切都很好 在每个文件夹(500+中)中,我都有一个名为“front.bmp”的

我正在开发一个应用程序来查找、播放和显示所有媒体,但主要是音乐。我正在vb.net中使用Visual Studio 2012。在我的表单上,我有一个Windows Media Player(WMP)和两个列表视图。第一个列表视图(lvFolders)显示驱动器位置的所有文件夹。当我选择一个文件夹时,它会自动将所有文件(媒体曲目)加载到第二个listview(lvPlaylist)中,并开始使用WMP播放第一个曲目。这一切都很好

在每个文件夹(500+中)中,我都有一个名为“front.bmp”的专辑封面。我一辈子都搞不清楚我做错了什么。当listview填充文件夹时,我试图让它将该文件夹中的每个图像文件加载到imagelist中,并使用该图像将文件夹显示为大图标。结果将是500多个大文件夹,每个文件夹显示imagelist中各自的相册封面

我特别不想使用文件夹浏览器对话框或打开文件对话框。此应用程序是我个人使用的基于触摸的应用程序

我附上了我的代码,以防它有助于理解我的困境

    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

里面没有“front.bmp”。你确定你的意思不是像
Dim strAlbumArt As String=strDir&“\front.bmp

My.Computer.FileSystem.GetName
从路径解析文件名,但在本例中,你传递的是
strDir
,它可能是“E:\Music\TEST”
Dim strAlbumArt As String=strDir&“\”的子目录front.bmp“
应该更像它。
Dim strAlbumArt As String = strDir & "\" & (My.Computer.FileSystem.GetName(strDir)) & ".bmp"