RSS 2.0 Feed
RSS 2.0


Atom 1.0 Feed
Atom 1.0

  Retrieving the Associated Icon for a File 


I got a class that does will retrieve the associated icon for a file, but never thought of posting it. Cathi Gero posted some code to make this a simple task so you can get the icon for a file in a single call (But it would be great if this were just built into the FileInfo class). Great stuff.

Icon myicon = ExtractIcon.GetIcon(mypath, true, false);




                   



Leave a comment below.

Comments

  1. Atul Buono 2/1/2005 2:00 PM
    Gravatar
    Is:

    Icon.FromHandle(new Bitmap(path).GetHicon());

    that bad?
  2. Ryan Farley 2/1/2005 2:09 PM
    Gravatar
    Hi Atul,

    Different result. The code mentioned in the post will get the icon associated with a file. For example, if you used the path to a zip file, you would get the icon associated with a zip file (ie: the icon you see for the file in Explorer). So if Winzip was the default app for zip files on your pc you'd get the winzip zip file icon. If WinRAR was the default, you'd get WinRAR's zip file icon.

    Your code will convert a bitmap to an icon, which is still useful, just accomplishes something different. Got it?

    -Ryan
Comments have been closed on this topic.



 

News


Also see my CRM Developer blog

Connect:              


Sponsor

Sections