Click here to Skip to main content
15,921,382 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Im using the code from MSDN[^] to extract icons from file.

I am creating an app launcher with listview, imagelist.

The problem is that only the first icon associated with respective file gets extracted.

So if i have 5 applications with 5 different icon, all 5 gets the icon from the first app.

Since the files in my listview will change over time, i cant specify icons either.

All tips are welcome.
lukeer 26-Nov-12 3:16am    
I bet you've altered the example to fit your needs. Please use the "Improve question" link to add the relevant part of your code (the part that adds items to the listview).
Member 9621169 1-Dec-12 5:38am    
Thanks! Works like a charm.
Tried to figure it out for hours, and such a simple solution it was.

1 solution

The MSDN sample you referenced add images to the ImageList using the file extension as image key.
Only an image at a time can be associated to a key, thus if you didn't changed this behavior, maybe you have to modify that line of code
imageList1.Images.Add(file.Extension, iconForFile);

should be changed into
imageList1.Images.Add(file.FullName, iconForFile);

or something more convenient.

the same applies to
item.ImageKey = file.Extension;

that should be changed into
item.ImageKey = file.FullName;

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900