private void pictureBox1_Click(object sender, EventArgs e)//保存图片 { OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = false;//该值确定是否可以选择多个文件 dialog.Title = "请选择文件"; dialog.Filter = "图片文件(*.jpg,*.png)|*.jpg;*.png"; if (dialog.ShowDialog() == DialogResult.OK) { string file = dialog.FileName; MessageBox.Show("图片以加载:" + file); jiDu = listBox2.SelectedItem.ToString(); // MessageBox.Show(jiDu); jieDuan = listBox1.SelectedItem.ToString(); // MessageBox.Show(jieDuan); string name = string.Format("{0:D}", dateTimePicker1.Value); string newfile = "G:\\Queen ant\\uart\\uart\\bin\\Debug\\growMemary_Iamge\\" + strname.Text.ToString() + "\\" + jiDu + "\\" + jieDuan + "\\" + name + ".jpg"; MessageBox.Show(newfile); ImageFile imageFile = new ImageFile(); imageFile.CopyFolder(file, newfile); /******************************/ string selectFidCommand = "SELECT id FROM detail WHERE name='" + strname.Text + "'"; MySqlDataReader reader2 = mysqlC.ExeQuery(selectFidCommand); if (reader2.Read()) { fid = reader2.GetInt32(reader2.GetOrdinal("id")); } insertDb(jieDuan, name, jiDu);//插入数据库 } }