Jon*_*an. 3 .net vb.net gdi+ image
我需要在从OFD打开后保存图像.这是我的代码atm:
Dim ofd As New OpenFileDialog
ofd.Multiselect = True
ofd.ShowDialog()
For Each File In ofd.FileNames
Image.FromFile(File).Save("C:\Users\Jonathan\Desktop\e\tmp.png", Imaging.ImageFormat.png)
Next
Run Code Online (Sandbox Code Playgroud)
在线上,Image.FromFile(File).Save("C:\Users\Jonathan\Desktop\e\tmp.png", Imaging.ImageFormat.png)它出现了错误.
(注意:应用程序将建立在这个只是我的第一个代码,它将需要保存而不是复制)
打开或保存图像会锁定文件.覆盖此文件需要首先在持有锁的Image对象上调用Dispose().
我真的不了解你的代码,但你必须这样做:
For Each File In ofd.FileNames
Using img As Image = Image.FromFile(File)
img.Save("C:\Users\Jonathan\Desktop\e\tmp.png", Imaging.ImageFormat.Png)
End Using
Next
Run Code Online (Sandbox Code Playgroud)
Using语句确保处理img对象并释放文件锁.