问题描述
我有以下 cod,它将启动 Windows 资源管理器并选择一个文件并最大化资源管理器.然后它将查找 Windows 资源管理器并将其最小化.我做了最大化-最小化,这样我就不必手动执行此操作(懒惰,我知道).我在我的代码中设置了此设置,仅在文件夹未打开时触发.如果它是打开的,那么只需运行最小化部分.代码如下:
I have the following cod that will start a Windows Explorer with a file selected and maximize Explorer. It then will look for the Windows Explorer and minimize it. I did the maximize-minimize so that I would not have to do this manually (lazy, I know). I have this set up in my code to trigger only when the folder is not open. If it is open, then just run the minimize part. Here's the code:
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
那么,我的问题是,是否可以让资源管理器在已打开的 Windows 资源管理器上选择文件?
So, my question is, can Explorer be told to select a file on an already opened Windows Explorer?
推荐答案
你可以直接解决.
Dim i = Shell("explorer /select, C:\Folder\File.exe", AppWinStyle.NormalFocus)
这篇关于在打开的 Windows 资源管理器上选择一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!