Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Extracting and displaying folder icons

Posted on 2004-10-25
Medium Priority
Last Modified: 2011-09-20
Hi everyone,

I'm having a problem to extract the "Folder Icon" on the disk drive, the only icon can be displayed on the list view is the file icon. Here is a part of my code:

Private Sub ShowFiles()
  Dim dir() As String
  Dim en As System.Collections.IEnumerator
  Dim myIcon As System.Drawing.Icon
  Dim shinfo As New SHFILEINFO
  Dim hImgSmall As IntPtr
  Dim hImgLarge As IntPtr
  Dim fName As String
  Dim fSize As String
  Dim fType As String
  Dim fModified As String

  dir = System.IO.Directory.GetFiles(cboxDrives.Text)
  lvwFiles.SmallImageList = ImageList2
  lvwFiles.LargeImageList = ImageList2
  shinfo.szDisplayName = New String(Chr(0), 260)
  shinfo.szTypeName = New String(Chr(0), 80)
  en = dir.GetEnumerator
  While en.MoveNext
     fName = CStr(en.Current)
     Dim fInfo As New System.IO.FileInfo(fName)
     fSize = Str(Math.Ceiling(fInfo.Length / 1024))
     fType = fInfo.Extension
     fModified = fInfo.LastWriteTime
     Dim fileItem As New Windows.Forms.ListViewIte(GetNameFromPathAndName _
                                      (fName), nIndex)
     Dim sub1 As New Windows.Forms.ListViewItem.ListViewSubItem(fileItem, _
                                          fSize + " KB")
     Dim sub2 As New Windows.Forms.ListViewItem.ListViewSubItem(fileItem,            
     Dim sub3 As New Windows.Forms.ListViewItem.ListViewSubItem(fileItem, _
     hImgSmall = SHGetFileInfo(fName, 0, shinfo, Marshal.SizeOf(shinfo), _
                         SHGFI_ICON Or SHGFI_SMALLICON)
     myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon)
     ImageList2.Images.Add(myIcon) 'Add icon to imageList.
     nIndex = nIndex + 1
  End While
End Sub

Can anyone please help how to do this in VB.Net??
Question by:uncivilizedpikinini
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 86

Accepted Solution

Mike Tomlinson earned 500 total points
ID: 12399817
The project here will show you how to do everything and anything you ever wanted to know about how to make a "windows explorer" type interface.  It is heavily commented and pretty easy to understand.



Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question