从资源管理器复制/粘贴时忽略文件夹

时间:2016-05-04 01:30:10

标签: vb.net vb.net-2010

我的问题是如何在从资源管理器复制并从剪贴板粘贴时忽略文件夹或目录,当您只从资源管理器复制文件时我的代码没问题但是当复制文件和文件夹时,我得到一个系统.IO.FileNotFoundException:找不到文件。谢谢

 Private Sub mnuPaste_Click(sender As System.Object, e As EventArgs)     Handles mnuPaste.Click
        '//if clipboard has a file drop list, paste the names of all files in this list in a datagridview
        If My.Computer.Clipboard.ContainsFileDropList Then
            Dim fileDropList As Specialized.StringCollection
            fileDropList = My.Computer.Clipboard.GetFileDropList()
            For Each fileName As String In fileDropList
                If strAllowedExtensions.Contains(Path.GetExtension(fileName).ToLower()) Then
                    InsertToList(fileName)
                Else
                    blnNotAllowed = True
                End If
            Next
            If blnNotAllowed = True Then
                MsgBox("Some of the files you paste is not supported, Please check the Help Contents for the list supported files.")
            End If
        Else
            MsgBox("Clipboard does not contain a file drop list", MsgBoxStyle.Exclamation And MsgBoxStyle.OkOnly)
        End If
    End Sub

0 个答案:

没有答案