Read the following code is an icon file, then displayed in the picture box code, but it can't identify the target icon file is a single figure or photos, also can't choose, ask how to identify multiple icon and select one of the pieces to display,
Private void button1_Click (object sender, EventArgs e)
{
DialogResult Dr=openFileDialog1. ShowDialog (this);
If (Dr==DialogResult. OK)
{
The string filename=openFileDialog1. Filename;
Icon picicon=Icon. ExtractAssociatedIcon (filename);
Image picimage=picicon. ToBitmap ();
PictureBox1. Image=picimage;
}
}
CodePudding user response:
https://blog.csdn.net/zgke/article/details/3279327Is this you want?