ho provato a usare .dispose ma restituisce un errore " Invalid Parameter"...
questo è il codice nella prima classe
class a
'eredita il controllo Picturebox
dim bmp as bitmap
Public sub New()
bmp = New Bitmap(Drawing.Image.FromFile(sContactFile))
gGraph = Graphics.FromImage(bmp)
End Sub
Public Sub ReleaseContacts()
bmp.Dispose()
gGraph.Dispose()
bmp = Nothing
gGraph = Nothing
End Sub
Public Function GetContacts() As Bitmap
Return bmp
End Function
end class
'salvo il bitmap da un altra classe:
class b
public sub closeme()
Dim bitTempBMP As Bitmap = a.GetContacts
a.ReleaseContacts()
a.Dispose()
If File.Exists(sContactFile) Then
File.Delete(sContactFile) '<--- "eccezione di tipo IO il file è utilizzado da una altro processo![]()
End If
bitTempBMP.Save(sContactFile, System.Drawing.Imaging.ImageFormat.Png)
end sub
end class