3

How can I retrieve the system icon associated with a file/folder so that I can show it in the list view adjacent to the file/folder name?

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124

2 Answers2

3

You need to use Icon.ExtractAssociatedIcon

 Icon icon = Icon.ExtractAssociatedIcon(filepath);

Take a look at Icon.ExtractAssociatedIcon documentation

Note: this works only for files. For folders you need P/Invoke sample is here Edit: Page is now defunct, please refer to this copy on the Wayback Machine.

Jonas Kohl
  • 837
  • 8
  • 25
Sriram Sakthivel
  • 69,953
  • 7
  • 104
  • 182
0

See Obtaining (and managing) file and folder icons using SHGetFileInfo in C#.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Burak Keceli
  • 883
  • 1
  • 14
  • 29