Here is a file that was passed to me a while a back from someone on the forums for extracting icons, add it to your project first. Here is what you're going to want to do after that:
Step 1: Add an image list to the project and go to your listview properties. Set the image list to the one you want. (For this example, we'll say that the listview is lvList and the image list is IM1)
Then modify this code as needed:
vb Code:
Private Sub lvList_DragEnter(ByVal sender As Object, ByVal e As DragEventArgs) Handles lvList.DragEnter
'If file drag/drop then
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
'Allow
e.Effect = DragDropEffects.All
End If
End Sub
vb Code:
Private Sub lvList_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles lvList.DragDrop
'Get file path
Dim values() As String = DirectCast(e.Data.GetData(DataFormats.FileDrop), String())
'Load file info from file path
Dim info As New IO.FileInfo(values(0))
'Create a new listview item
Dim item As New ListViewItem
'Create icon extractor
Dim extractor As New IconExtractor
'Extract icon to IM1
'Note that this line is where the extraction of the icon occurs!
IM1.Images.Add(extractor.Extract(info.FullName, IconSize.Large))
'Set item text to file name without extension
item.Text = IO.Path.GetFileNameWithoutExtension(info.FullName)
'Set item image index
item.ImageIndex = iImages
'Set item tag to file path
item.Tag = info.FullName
'Add item to list view
lvList.Items.Add(item)
'Incriment image index
iImages += 1
End Sub