private void btnHeadImg_Click(object sender, EventArgs e) { DGVSelect(); OpenFileDialog openfile = new OpenFileDialog(); openfile.Title = "请选择本地的一张图片"; openfile.Filter = "Login图片(*.jpg;*.bmp;*png)|*.jpeg;*.jpg;*.bmp;*.png|AllFiles(*.*)|*.*"; if (DialogResult.OK == openfile.ShowDialog()) { try { //读成二进制 byte[] bytes = File.ReadAllBytes(openfile.FileName); if (AdminManage.InsertCorImg(bytes, id)) { MessageBox.Show("修改成功!"); } else { MessageBox.Show("修改失败!"); return; } pictureBox1.Image = System.Drawing.Image.FromStream(new MemoryStream(bytes)); pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; } catch { MessageBox.Show("出错了!"); } } }