This is how the project goes:
At startup the form loads a image from a predefined source:
Me.BackgroundImage = Image.FromFile("C:\img1.bmp")
I've made a button that replaces the image with another image selected by the user:
Dim newsbmp As New OpenFileDialog
newsbmp.InitialDirectory = Environment.GetFolderPath(SpecialFolder.DesktopDirectory)
If newsbmp.ShowDialog = Windows.Forms.DialogResult.OK Then
Try
Me.BackgroundImage = Image.FromFile(newsbmp.FileName)
Catch ex As Exception
Me.BackgroundImage = Image.FromFile("C:\img1.bmp")
MsgBox(ex, MsgBoxStyle.Critical)
End Try
End If
Now what i want to do is if the image loads correctly the old/predefined image "img1" to be replaced in the same directory with the same name by the picture selected by the user.
I can't delete the image since it say that the image is being used by the application.
Any help?
Thanks

New Topic/Question
Reply



MultiQuote





|