【问题标题】:how to set current image location in vb.net如何在 vb.net 中设置当前图像位置
【发布时间】:2014-06-06 10:34:06
【问题描述】:

如果我使用拖放,如何在 vb.net 中设置当前图像位置。 似乎图像位置不起作用,因为我尝试使用消息框输出图像位置。但它没有显示任何东西。如何获取刚刚放入图片框中的文件的图像位置,以便可以将其传输到另一个目录?

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

【问题讨论】:

  • 与您的问题分开,但使用 Path.Combine("C:\pics", textbox1.text + ".jpg")。还将“C:\pics”部分抽象为配置元素。

标签: vb.net


【解决方案1】:

为什么不将e.Data.GetData(DataFormats.FileDrop), Array).GetValue(0).ToString 保存到变量中?那就是您要查找的文件路径。不知道为什么 ImageLocation 属性在这里不起作用。

【讨论】:

  • FileToMove = CType(e.Data.GetData(DataFormats.FileDrop), Array).GetValue(0).ToString - 如果我这样做,它将不起作用
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多