Findel
New member
- Joined
- Aug 5, 2005
- Messages
- 2
- Programming Experience
- 3-5
I'm trying to save and overwrite an image that has been loaded into a PictureBox and then changed. The application won't let me overwrite the original file, but it will let me save it with a different name. I think that the original file is being locked, but I am not sure how to unlock it.
here's some of my code
Private Sub openTargetFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles openTargetFile.Click
targetFileDialog.Filter = "Image Files(*.JPG)|*.JPG"
If Not targetFileDialog.ShowDialog = DialogResult.Cancel Then
targetImage = Image.FromFile(targetFileDialog.FileName)
'targetFilePath = Replace(targetFileDialog.FileName, ".jpg", "_withExif.jpg") ' this targetFilePath will save fine
targetFilePath = targetFileDialog.FileName
targetFileBox.Image = getThumb(targetImage)
End If
targetFileDialog.Dispose()
enambleCopy()
End Sub
Private Sub copyExifButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles copyExifButton.Click
Dim propItem As System.Drawing.Imaging.PropertyItem
For Each propItem In sourceImage.PropertyItems
targetImage.SetPropertyItem(propItem)
Next
targetImage.Save(targetFilePath)
feedBackMessage.Text = "Copy Complete!" & vbCrLf & "File Saved as: " & targetFilePath
feedBackMessage.Visible = True
End Sub
Any ideas why it wont save?
Any help would be great, many thanks in advance!
Findel
here's some of my code
Private Sub openTargetFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles openTargetFile.Click
targetFileDialog.Filter = "Image Files(*.JPG)|*.JPG"
If Not targetFileDialog.ShowDialog = DialogResult.Cancel Then
targetImage = Image.FromFile(targetFileDialog.FileName)
'targetFilePath = Replace(targetFileDialog.FileName, ".jpg", "_withExif.jpg") ' this targetFilePath will save fine
targetFilePath = targetFileDialog.FileName
targetFileBox.Image = getThumb(targetImage)
End If
targetFileDialog.Dispose()
enambleCopy()
End Sub
Private Sub copyExifButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles copyExifButton.Click
Dim propItem As System.Drawing.Imaging.PropertyItem
For Each propItem In sourceImage.PropertyItems
targetImage.SetPropertyItem(propItem)
Next
targetImage.Save(targetFilePath)
feedBackMessage.Text = "Copy Complete!" & vbCrLf & "File Saved as: " & targetFilePath
feedBackMessage.Visible = True
End Sub
Any ideas why it wont save?
Any help would be great, many thanks in advance!
Findel