To get the associated icon of a file simply use the below code
Icon fileicon = Icon.ExtractAssociatedIcon(@"c:\example.txt");
//set the icon of our Form to the specified icon
this.Icon = fileicon;
To show the icon in a PictureBox (eg:-pictureBox1) convert it to bitmap as given below
pictureBox1.Image = fileicon.ToBitmap();
we can obtain the icon of an 'exe' file using the above method.
Icon fileicon = Icon.ExtractAssociatedIcon(@"c:\example.txt");
//set the icon of our Form to the specified icon
this.Icon = fileicon;
To show the icon in a PictureBox (eg:-pictureBox1) convert it to bitmap as given below
pictureBox1.Image = fileicon.ToBitmap();
we can obtain the icon of an 'exe' file using the above method.
Comments
Post a Comment