vb.net - Free an image that is allocated in a form -
i have load image , delete timer, not possible unless release image resource, code is:
pic=image.fromfile(directory.getcurrentdirectory+ "s.png")
this image replaced timer code, not able replace because showing image s.png
. how can write s.png
while showing , reload it? tell me method can free resource s.png
other programs can modify it.
try reading image info memory , creating image
that:
dim stream = new memorystream(file.readallbytes(directory.getcurrentdirectory() & "s.png")) dim pic = image.fromstream(stream)
you need maintain stream open lifetime of image
, when image file replaced , re-reading it, phone call dispose
on both stream
, pic
before recreating them.
vb.net
No comments:
Post a Comment