以下代码在普通文件夹中有效,但在Vault中不起作用(solidworks epdm)
更多信息,如果我的计算机上的任何文件夹中的任何文件被选中(聚焦或突出显示),则上面的代码可以100%工作。但是我的C:Drive上有一个EPDM SolidWorks Vault文件夹,在此库文件夹中有上面的代码没有为我提供所选项目,它给了我一个空白值。没有错误
Imports Shell32
Imports SHDocVw
Imports System.IO
Public Class Form1
Private Function GetExplorerSelectedFiles() As String()
Dim ExplorerFiles As New List(Of String)
Dim exShell As New Shell
For Each window As ShellBrowserWindow In DirectCast(exShell.Windows, IShellWindows)
If TryCast(window.Document, IShellFolderViewDual) IsNot Nothing Then
For Each fi As FolderItem In DirectCast(window.Document, IShellFolderViewDual).SelectedItems
ExplorerFiles.Add(fi.Name)
Next
ElseIf TryCast(window.Document, ShellFolderView) IsNot Nothing Then
For Each fi As FolderItem In DirectCast(window.Document, ShellFolderView).SelectedItems
ExplorerFiles.Add(fi.Name)
Next
End If
Next
Return ExplorerFiles.ToArray
End Function
Private Sub btntest_Click(sender As Object, e As EventArgs) Handles btntest.Click
Dim files = GetExplorerSelectedFiles()
Dim file As String = String.Join(".", files)
Label1.Text = file
End Sub
End Class