JPG file being kept as accessed by program
- From: Lloyd Sheen <a@xxx>
- Date: Mon, 18 Aug 2008 14:47:20 -0400
I have a problem in a program in which a jpg file which is being used to load the Image of a picturebox is being kept after the load.
The code is as follows:
Public ReadOnly Property ImageUrl() As Image
Get
If theImage Is Nothing Then
Dim jpgs() As String = Directory.GetFiles(Me.FolderName, "*.jpg")
If jpgs.Length > 0 Then
Try
Dim theTempImage As Image = Image.FromFile(jpgs(0))
theImage = CType(theTempImage.Clone, Image)
theTempImage.Dispose()
'theImage = Image.FromFile(jpgs(0))
Catch ex As Exception
Dim x As Integer = 1
Return Nothing
End Try
Return theImage
Else
Return Nothing
End If
Else
Return theImage
End If
End Get
End Property
As you can see I tried to get rid of the problem by cloning the first image and then disposing it to get rid of the "reference" to the jpg file. That does not work.
The problem occurs in the app if I attempt to delete the folder while it is being shown in a list (the ImageURL property is used for databinding).
Any ideas on how to load the image without keeping a reference to the file?
Thanks
LS
.
- Follow-Ups:
- Re: JPG file being kept as accessed by program
- From: Bill McCarthy
- Re: JPG file being kept as accessed by program
- Prev by Date: Re: char[4] data type in c for storing IPs - VB.NET equivalence
- Next by Date: Re: Share Class Library over network???
- Previous by thread: Find NULL in DataView
- Next by thread: Re: JPG file being kept as accessed by program
- Index(es):
Relevant Pages
|