还有什么需要释放资源?
Dim MemoryGraphics As Graphics
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
PictureBox1.Image = Image.FromFile("c:\111.JPG")
MemoryGraphics = Graphics.FromImage(PictureBox1.Image)
Dim rectangle1 As New Rectangle(0, 0, 400, 300)
MemoryGraphics.FillRectangle(Brushes.White, rectangle1)
PictureBox1.Image.Save("c:\222.JPG", System.Drawing.Imaging.ImageFormat.Bmp)
PictureBox1.Dispose()
MemoryGraphics.Dispose()
My.Computer.FileSystem.DeleteFile("c:\111.JPG")
End Sub
My.Computer.FileSystem.DeleteFile("c:\111.JPG")这句提示:
文件“c:\111.JPG”正由另一进程使用,因此该进程无法访问此文件。
[解决办法]
应该是这句
PictureBox1.Image.Dispose()