Osman Beyazmursel
Osman Beyazmursel

Reputation: 59

How to get the system icon for any file/folder

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?

Upvotes: 3

Views: 12606

Answers (2)

Sriram Sakthivel
Sriram Sakthivel

Reputation: 73502

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.

Upvotes: 3

Related Questions