在打开的 Windows 资源管理器上选择一个文件

Joe*_*oeB 4 vb.net

我有以下 cod,它将启动 Windows 资源管理器并选择一个文件并最大化资源管理器。然后它将查找 Windows 资源管理器并将其最小化。我做了最大化-最小化,这样我就不必手动执行此操作(懒惰,我知道)。我在我的代码中设置了此设置,仅在文件夹未打开时触发。如果它是打开的,那么只需运行最小化部分。这是代码:

If Not FolderIsOpen Then
    Dim curProcess As Process = New Process()
    With curProcess
        With .StartInfo
            .FileName = "explorer.exe"
            Dim MinimizeName As String = RegScoringWorkbookName.Replace(".xlsm", ".zip")
            .Arguments = String.Format("/select, ""{0}""", MinimizeName)
            .WindowStyle = ProcessWindowStyle.Maximized
        End With
        .Start()
    End With
    Thread.SpinWait(100000000)
    For Each IWindow As InternetExplorer In SHWindows
        If IWindow.Name = "Windows Explorer" Then
            Dim GetURIPath As New Uri(IWindow.LocationURL)
            If GetURIPath.LocalPath.ToLower.Equals(FolderName) Then
                ShowWindow(CType(IWindow.HWND, IntPtr), SW_SHOWMINIMIZED)
                Exit For
            End If
        End If
    Next IWindow
Else
    For Each IWindow As InternetExplorer In SHWindows
        If IWindow.Name = "Windows Explorer" Then
            Dim GetURIPath As New Uri(IWindow.LocationURL)
            If GetURIPath.LocalPath.ToLower.Equals(FolderName) Then

                'Code here to select the targeted file

                ShowWindow(CType(IWindow.HWND, IntPtr), SW_SHOWMINIMIZED)
                Exit For
            End If
        End If
    Next IWindow
End If
Run Code Online (Sandbox Code Playgroud)

所以,我的问题是,是否可以告诉资源管理器在已打开的 Windows 资源管理器上选择文件?

Jas*_*hes 5

你可以把它掏出来。

Dim i = Shell("explorer /select, C:\Folder\File.exe", AppWinStyle.NormalFocus)
Run Code Online (Sandbox Code Playgroud)