有没有办法启动资源管理器窗口并使用 WPF 突出显示该文件夹中的文件?我已经尝试过以下方法:
Process ExplorerWindowProcess = new Process();
ExplorerWindowProcess.StartInfo.FileName = "explorer.exe";
ExplorerWindowProcess.StartInfo.Arguments = ConfigFile.File.FullName;
ExplorerWindowProcess.Start();
... 但是这会在 Windows 资源管理器中使用默认应用程序打开文件(在我的例子中是一个 XML 文件),这是我非常不想要的。我知道可用于 Eclipse 的 Aptana 工具允许您在 Eclipse 项目浏览器中选择一个文件并完全按照我的需要在资源管理器中显示该文件,但我需要一种在我的 WPF 应用程序中实现此功能的方法。
最佳答案
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.
You will also want to put quotes around the filename like so:
startInfo.FileName = "explorer.exe";
startInfo.Arguments = "/select,\"" + ConfigFile.File.FullName + "\"";
关于wpf - 打开文件夹并使用 WPF 突出显示特定文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2169942/