Overwriting picture

jimday1982

Member
Joined
Jul 30, 2003
Messages
22
Location
Va Beach
Hi, I have a program that lets the user open a picture and make changes to it, but when trying to save the picture, it says that the file is currently in use and cannot be saved. Is there any way around this? Thanks!
 
The code we have for opening the picture is:



Code:
Private Sub btnPic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPic.Click
        Open dialog box to import a picture

        With ofd
            .CheckFileExists = True
            .CheckPathExists = True
            .Filter = "Images|*.bmp;*.tiff;*.jpg;*.jpeg;*.png;"
            .Multiselect = False
            .ShowHelp = False
            .Title = "Select an Image"
        End With

        If ofd.ShowDialog() = DialogResult.OK Then

            Dim tmpBMP As New Bitmap(ofd.FileName)
            CoverPic.Image = tmpBMP
        End If


    End Sub

Thanks!
 
Ok, this is probably the problem. We are opening the picture by calling the location (c:\blah\blah.jpg) which is stored in a text file.

Code:
txtcoverpic.Text = objReader.ReadLine
            If txtcoverpic.Text  = "" Then
                CoverPic.Image = Image.FromFile(txtcoverpic.Text)
            End If

How do we go about closing the file so we can overwrite it? Thanks!
 
Back
Top