There are probably several problems here: the one you have noticed, and the one you haven't, not yet...
Without your code we can;t tell, but the chances are that you are loading the image using
Image.FromFile Method (String) (System.Drawing)[
^] or one of it's overloads - and the documentation clearly states:
Quote:
The file remains locked until the Image is disposed.
Which means that while the Image instance exists in your app, teh soure fiule of the image is in use, it cannot be opened for writing, or deleted.
The way round this is to use Image.FromFile to load the image, copy it, then Dispose the original:
Public Function GetImage(ByVal path As String) As Image
Using im As Image = Image.FromFile(path)
Return New Bitmap(im)
End Using
End Function
The original file is then no longer locked and can be overwritten or deleted.
But that's just the problem you have noticed - there is a bigger one looming on the horizon. Your app will fail in production, because you are using the EXE file folder to store data - and in production, that will be under the "Program Files" folder, which is not writable without admin permissions. See here:
Where should I store my data?[
^] - the code is in C#, but it's trivial to convert to VB.