有没有办法启动资源管理器窗口并使用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应用程序中实现的方法。
Explorer命令行参数
http://support.microsoft.com/kb/152457
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 + "\"";