2013-08-19 40 views
0

我正在开发一个应用程序来查找,播放和显示所有媒体,但主要是音乐。我在vb.net中使用Visual Studio 2012。在我的表单中,我有一个Windows媒体播放器(WMP)和两个列表视图。第一个列表视图(lvFolders)显示驱动器位置的所有文件夹。当我选择一个文件夹时,它会自动将所有文件(媒体轨道)加载到第二个列表视图(lvPlaylist)中,并开始使用WMP播放第一个轨道。这一切运作良好。在Listview中为每个文件夹分配一个图像(文件夹)

在每个这些文件夹(500+)中,我都有一个名为“front.bmp”的专辑封面。我不能为我的生活弄清楚我做错了什么。由于列表视图正在填充文件夹,因此我试图将该文件夹中的每个图像文件加载到图像列表中,并使用该图像将文件夹显示为大图标。结果将是500个以上的大文件夹,每个文件夹显示来自图像列表的各自专辑封面。

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

我附上我的代码以防止它理解我的困境。

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 
+0

'My.Computer.FileSystem.GetName'确实解析路径中的文件名,但是在这种情况下,您将'strDir'作为gonne的子目录作为“E:\ Music \ TEST”的子目录Dim DimAlbumArt As String = strDir&“\”&“front.bmp”'应该更喜欢它。 –

回答

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

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

相关问题