如何获取拖放文件名以在VB中显示服务器名称而不是驱动器名称

时间:2015-07-23 18:15:01

标签: vb.net path drag-and-drop server

我目前正在使用VB中的程序,我有一个文本框,我将文件拖入其中,然后该文件的路径显示在文本框中。问题是这些文件存储在多个不同的服务器上,而不是显示服务器路径,而是显示该特定计算机上该服务器上关联的驱动器号。因此它显示为driveLetter:\ folder \ file,它应显示为\ server \ serverName \ folder \ file。这是代码。有什么建议吗?

Private Sub Form1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragEnter
    If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
        e.Effect = DragDropEffects.Copy
    Else
        e.Effect = DragDropEffects.None
    End If
End Sub

Private Sub Form1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
    Dim link() As String = e.Data.GetData(DataFormats.FileDrop)
    For Each path In link
        LclTxt.Text = path
    Next
End Sub

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    Me.AllowDrop = True
End Sub

0 个答案:

没有答案