1
從Windows資源管理器瀏覽的Ftp文件夾中拖動文件時,可以使用下一個代碼讀取文件名。 但是有沒有辦法檢索完整的Ftp路徑?通過拖放檢索FTP文件的完整路徑?
Private Sub DataGridView1_DragDrop(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragDrop
Dim filename As String = ""
If e.Data.GetDataPresent("UniformResourceLocator") Then
Dim ioStream As System.IO.Stream = DirectCast(e.Data.GetData("FileGroupDescriptor"), System.IO.Stream)
Dim contents As Byte() = New [Byte](511) {}
ioStream.Read(contents, 0, 512)
ioStream.Close()
Dim sb As New System.Text.StringBuilder()
Dim i As Integer = 76
While contents(i) <> 0
sb.Append(CChar(ChrW(contents(i))))
i += 1
End While
filename = sb.ToString()
End If
End Sub