Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get associated icon from file, folder or drive without WinAPI

Tags:

c#

.net

icons

Is there a way to get an associated icon in C# without using any DllImports?

When I use Icon.ExtractAssociatedIcon I don't seem to get the icon for drives, folders, SpecialFolder's in Environment or any files on network attached folders. So is there any other way to get an icon using .NET?

like image 589
Patrick Avatar asked Jun 16 '09 06:06

Patrick


1 Answers

.Net have only one method for extracting associated icons, and you already mentioned about it. Every lib you can find uses pinvokes, because they get icons from windows. So if you need to fully portable icon extraction engine, you must write it by yourself, sadly, but this is the only way (and hide all system specific code inside).

like image 149
arbiter Avatar answered Oct 18 '22 16:10

arbiter