使当前的explorer.exe窗口选择一个文件 [英] Make current explorer.exe window select a file
问题描述
我的程序在后台运行,并且我想要它,因为例如在我的音乐"文件夹中打开了explorer.exe窗口以选择(未打开)"test.txt".但是,当我运行我的代码时(见下文),它将打开一个新窗口,其中包含所选文件.我希望它只是在已经打开的窗口中选择文件.
my program runs on the background and I wanted it, given that I have explorer.exe windows open for example in My Music folder to select(Not open) "test.txt". But when I run my code(see below) It opens a new window with the file selected. I want it to just select the file, on the window that's already open.
代码:
string pathname = "c:\DocTest\Test.txt";
ProcessStartInfo l_psi = new ProcessStartInfo();
l_psi.Filename = "Explorer";
l_psi.Arguments = string.Format(@"/select, " + @ "" + pathname);
l_psi.UseShellExecute=true;
Process l_newProcess = new Process();
l.newProcess.StartInfo = l_psi;
l_newProcess.Start();
请记住两点:
-我不希望它打开文件,仅在文件夹中选择它
-我不希望它打开新的资源管理器窗口,只需使用已经打开的窗口
Please remember the two points:
-I don't want it to open the file, only to select it on a folder
-I don't want it to open a new explorer window, just use the one that's already open
感谢您的阅读:)
推荐答案
语法
EXPLORER.EXE [/n] [/e] [,/root,] [[,/select],]开关
EXPLORER.EXE [/n][/e][,/root,][[,/select],] Switches
/n:在单窗格(我的电脑")视图中为每个窗口打开一个新窗口物品即使新窗口复制了一个已经打开.
/n: Opens a new window in single-paned (My Computer) view for each item selected, even if the new window duplicates a window that is already open.
/e:使用Windows资源管理器视图.Windows资源管理器视图最相似Windows版本3.x中的文件管理器.请注意,默认视图是打开"视图.
/e: Uses Windows Explorer view. Windows Explorer view is most similar to File Manager in Windows version 3.x. Note that the default view is Open view.
/root ,:指定指定视图的根级别.这默认是使用普通名称空间根目录(桌面).所指定的是根目录的根显示.
/root,: Specifies the root level of the specified view. The default is to use the normal namespace root (the desktop). Whatever is specified is the root for the display.
/select ,:指定要接收初始文件的文件夹重点.如果使用"/select",则父文件夹打开,并选择了指定的对象.
/select,: Specifies the folder to receive the initial focus. If "/select" is used, the parent folder is opened and the specified object is selected.
没有提及重复使用打开的资源管理器,因此不可能.
There is no mention of reusing an open Explorer, so it might not be possible.
这篇关于使当前的explorer.exe窗口选择一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!