有没有办法启动资源管理器窗口并使用WPF突出显示该文件夹中的文件?我已经尝试了以下内容:
Process ExplorerWindowProcess = new Process();
ExplorerWindowProcess.StartInfo.FileName = "explorer.exe";
ExplorerWindowProcess.StartInfo.Arguments = ConfigFile.File.FullName;
ExplorerWindowProcess.Start();
...但是在Windows资源管理器中使用默认应用程序打开文件(在我的情况下是一个XML文件),我非常不想要。我知道可用于Eclipse的Aptana工具允许您在Eclipse项目浏览器中选择一个文件并在Explorer中完全按照我的意愿显示该文件,但我需要一种方法在我的WPF应用程序中实现它。
答案 0 :(得分:30)
Explorer命令行参数
http://support.microsoft.com/kb/152457
Explorer [/n] [/e] [(,)/root,<object>] [/select,<object>] /n Opens a new single-pane window for the default selection. This is usually the root of the drive Windows is installed on. If the window is already open, a duplicate opens. /e Opens Windows Explorer in its default view. /root,<object> Opens a window view of the specified object. /select,<object> Opens a window view with the specified folder, file or application selected.
您还需要在文件名周围加上引号,如下所示:
startInfo.FileName = "explorer.exe";
startInfo.Arguments = "/select,\"" + ConfigFile.File.FullName + "\"";