Results 1 to 8 of 8

Thread: [RESOLVED] [2005] ExtractAssociatedIcon for folders?

Threaded View

  1. #1

    Thread Starter
    Fanatic Member arsmakman's Avatar
    Join Date
    Dec 2001
    Location
    Leiden, Netherlands.
    Posts
    719

    Resolved [RESOLVED] [2005] ExtractAssociatedIcon for folders?

    Hello everyone,

    I am making an application that has a treeview control that should show the drives and their folders of the user's system. To make this a good overview, it would be nice if the icons that go with the folder or drive are shown in the treeview.

    Drawing.Icon.ExtractAssociatedIcon works great for files, but tells me 'File not found' when I try to extract the icon of a folder.

    This is the code I have now to add the C-drive's treeviewnode:
    VB Code:
    1. Dim nodeNew As New TreeNode
    2. nodeNew.Text = "C:\"
    3. nodeNew.Tag = "C:\"
    4.  
    5. Dim MyIcon As Drawing.Bitmap = Drawing.Icon.ExtractAssociatedIcon("C:\").ToBitmap()
    6. 'The line above gives me a file-not-found error.
    7.  
    8. Dim imlIcons As New ImageList
    9. imlIcons.Images.Add(MyIcon)
    10. nodeNew.ImageIndex = imlIcons.Images.Count - 1
    11.  
    12. tvwFolder.ImageList = imlIcons
    13. tvwFolder.Nodes.Add(nodeNew)
    Is there a way in VB.NET to extract icons from folders and drives?

    Thanks for your help,

    Alexander.

    P.S. On a side note, is there a way to set the image for a treeview node without the use of an imagelist?
    Last edited by arsmakman; Jul 15th, 2006 at 07:49 AM.
    No matter how fool-proof your program is, there will always be a better fool.

    Was a post helpful to you? Rate it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width