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
Showing file icon in the picuture box
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Vikrant Jadhav64 reputationPosted Dec 16, 2011, 2:58 AM EST
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.