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,738
  • 21
  • 105
  • 131

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
  • 1,018
  • 1
  • 11
  • 28
Sriram Sakthivel
  • 72,067
  • 7
  • 111
  • 189
0

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Burak Keceli
  • 933
  • 1
  • 15
  • 31