how to set current image location in vb.net
How do I set the current image location in vb.net if I use the drag and drop even. It seems like the imagelocation doesn't work because I tried outputting the image location using messagebox. But it didn't show up anything. How do I get the image location of the file that I have just drop into the picturebox so that I could transfer it on another directory?
Private Sub pb_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles pb.DragDrop
Dim FileToMove As String
Dim MoveLocation As String开发者_开发知识库
Try
pb.Image = Image.FromFile(CType(e.Data.GetData(DataFormats.FileDrop), Array).GetValue(0).ToString)
FileToMove = pb.ImageLocation
MoveLocation = "C:\pics\" + TextBox1.Text + ".jpg" '"
If System.IO.File.Exists(FileToMove) = True Then
System.IO.File.Move(FileToMove, MoveLocation)
End If
Catch ex As Exception
MessageBox.Show("Error Doing Drag/Drop")
End Try
End Sub
Why don't you save e.Data.GetData(DataFormats.FileDrop), Array).GetValue(0).ToString
to a variable? That is the file path you are looking for. Not sure why ImageLocation
property does not work here.
精彩评论