We are developing archiving software. Here we are storing different file type in the folder. when the user select the path of the file , we should show the respective file icon in the picuture box.
I will not store the file icon anywhere and i should take it dynamically. e.g Powerpoint files,MSWord,MSExcel
Loading
Vikrant JadhavPosted Dec 16, 2011, 7:58 AM
Use the Following Code it Will help You
private void button1_Click(object sender, EventArgs e)
{
DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
Icon icon = Icon.ExtractAssociatedIcon(openFileDialog1.FileName);
this.Icon = icon;
pictureBox1.Image = icon.ToBitmap();
}
}
Above code will display the Icon of respective File Type in Picturebox.
Thanks & Regards,
Vikrant Jadhav
Please Mark as a Correct Answer if above post is helpful to you.