i have this simple code for reading image from file
pic = Application.StartupPath & "\medlem" & "\" & txtp.Text & ".jpg"
Dim myimage As New Bitmap(pic)
Try
If File.Exists(pic) = True Then
PictureBox1.Image = myimage
ElseIf File.Exists(pic) = False Then
' PictureBox1.Image = My.Resources.siluett3
End If
Catch ex As Exception
MsgBox(ex)
End Try
but i cant the user to be able to overwrite the file.
but i cant. because my program is using the file.
here is the code for the event the is going to overwrite the file
Try
If Formspara.ShowDialog = DialogResult.Yes Then
If File.Exists(SAVE_PATH & "\" & Form1.txtp.Text & ".jpg") = True Then
Response = MessageBox.Show("The file '" & fso.GetName(Form1.txtp.Text & ".jpg").ToLower & "' already exist in the destination folder '" & _
SAVE_PATH & "'" & vbCrLf & vbCrLf & "Do you want to overwite it?", Text, MessageBoxButtons.YesNo, _
MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
'If Response = Windows.Forms.DialogResult.Yes Then
' Form1.pic = Application.StartupPath & "\medlem\laddar.jpg"
' File.Delete(SAVE_PATH & "\" & Form1.txtp.Text & ".jpg")
' bmap.Save(SAVE_PATH & "\" & Form1.txtp.Text & ".jpg")
'End If
If Response = Windows.Forms.DialogResult.No Then Exit Sub
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Try
bmap.Save(SAVE_PATH & "\" & Form1.txtp.Text & ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
the new image comes from the computers web camera.
the only thing i cant get to work is how to overwrite the file.
anyone that knows how to do?
thanks in advance :)
This post has been edited by EndLessMind: 07 February 2010 - 04:02 AM

New Topic/Question
Reply




MultiQuote



|