C# 往pictruebox 中插入图片 通过openfiledialog 浏览本地图片 选择图片插入pictruebox. 求代码

没财富了…………

openFileDialog1.Filter = "jpg files (*.jpg)|*.jpg";//给定选中图片的格式
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string id = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString()+ DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString()+DateTime.Now.Millisecond.ToString();
File.Copy(openFileDialog1.FileName,Application.StartupPath + "\\Image\\" + id + ".jpg");//对选中的图片重新命名 ,并保存在Debug下Image文件中
pictureBox1.Image = Image.FromFile(Application.StartupPath + "\\Image\\" + id + ".jpg");//显示在pictureBox中
}
温馨提示:内容为网友见解,仅供参考
第1个回答  2012-06-06
this.pictureBox1.Image = Image.FromFile(this.openFileDialog1.FileName);

C# 往pictruebox 中插入图片 通过openfiledialog 浏览本地图片 选择...
openFileDialog1.Filter = "jpg files (*.jpg)|*.jpg";\/\/给定选中图片的格式 if (openFileDialog1.ShowDialog() == DialogResult.OK){ string id = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString()+ DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime....

相似回答