用Save来保存图像,为什么不可以用相同的名字来覆盖掉原来的图片?那要怎么才能覆盖图片?
我的代码如下
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "位图文件(*jpeg)|*.jpg|BMP(*.bmp)|*.bmp";
openFileDialog1.FilterIndex = 4;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
FileName = openFileDialog1.FileName;
Bitmap pic = new Bitmap(FileName);
this.textBox1.Text = FileName;
pictureBox1.Image = pic;
string shortName = FileName.Substring(FileName.LastIndexOf("\\") + 1);
string adr = AppDomain.CurrentDomain.BaseDirectory shortName;
textBox2.Text = adr;
pictureBox1.Image.Save(adr);
Bitmap ic = new Bitmap(adr);
this.pictureBox2.Image = ic;
Image myThumbnail = ic.GetThumbnailImage(80, 100, null, IntPtr.Zero);
MessageBox.Show("ok");
}
}
如果保存相同的图片两次就出错,说“GDI+发生一般性错误”
但是如果不是相同的图片就不会出错。怎么解决阿