Update: This approach is only to show one of the hidden gems in the .net framework and not to steal copyrighted icons.
Icons of other programs should only be used after owner approval.
Have you ever seen a file with a pretty icon you wanted to use but you couldn't get a similar one in your program?
If yes, try this method >> Icon.ExtractAssociatedIcon here is the code I wrote that works fine, you will also find the sample attached
ico = this.Icon;
private void btnGetIcon_Click(object sender, EventArgs e)
if(dlgOpen.ShowDialog() == DialogResult.OK)
ico = Icon.ExtractAssociatedIcon(dlgOpen.FileName);
this.Icon = ico;
private void pnlIcon_Paint(object sender, PaintEventArgs e)
3 replies on “Extracting Icons from Files”
Have you ever seen a file with a pretty icon you wanted to use but you couldn’t get a similar one in your program? Do you think that other artists are simply to be copied, regardless of the hours of work that they put in to create the icon? Is copyright law just a scam to protect big industrial players and not to protect the little guys too?
Answer YES to all three? Well, go ahead and rip off my work, thanks.
No, Ofcourse the post has been updated due to your comment, thank you.