我想将文件拖放到按钮上,并将文件名称不带扩展名存储到文本框中。帮助摆脱这个问题。我在这些代码上遇到了一些错误。
tf.gradients(L,z[i]) * tf.gradients(L,z[j])
答案 0 :(得分:1)
我觉得你错过了将AllowDrop功能设置为true 并且还有一个函数来获取没有扩展名“GetFileNameWithoutExtension”的文件名 检查下面的代码
Imports System.IO
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Button5.AllowDrop = True
End Sub
Private Sub Button5_DragDrop(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles Button5.DragDrop
Dim files() As String = e.Data.GetData(DataFormats.FileDrop)
For Each indpath In files
TextBox1.Text = Path.GetFileNameWithoutExtension(indpath) & vbNewLine & TextBox1.Text
Next
End Sub
Private Sub Button5_DragEnter(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles Button5.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.Copy
End If
End Sub
End Class