【发布时间】:2012-01-27 18:26:31
【问题描述】:
我正在尝试将图像保存到已知路径:openFileDialog 的文件名
但是,我不断收到相同的错误:
“GDI+ 中出现一般错误。” 要么 "值不能为空。参数名称:文件名
我试过这样的东西:
pictureBox1.Image.Save(openFiles.FileName); // gives me "A generic error occurred in GDI+."
还有
pictureBox1.Image.Save(pictureBox1.ImageLocation); // gives me "Value cannot be null. Parameter name: filename"
基本上,我想做的就是将图像保存到已经建立的路径中。就像在 MSPaint 中打开图像、在其上绘图并保存一样 - 没有出现对话框,它只是保存到 openFileDialog 的路径。
我无法,为了我的一生,弄清楚如何做到这一点!
感谢您的任何帮助!
谢谢!
【问题讨论】:
-
您必须在您最初加载的位图上调用 Dispose()。这会释放 Image.FromFile() 对文件的锁定。
-
我试过了,但我仍然得到 Generic GDI+ 错误。 :S
标签: c# winforms image picturebox openfiledialog