wpf - 打开文件夹并使用 WPF 突出显示特定文件

标签 wpf windows process explorer

有没有办法启动资源管理器窗口并使用 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/

相关文章:

c# - 发布两个不同版本应用程序的工作流程

wpf - XAML 编辑选项

c# - MenuItem 可见性基于子菜单项状态

Java - 使用 JNA 的 Windows 任务栏 - 如何将窗口图标 (HICON) 转换为 Java 图像?

windows - Windows上的Docker - 证书错误

c - 确定 CPU 利用率 - Solaris unix

c# - 子窗口显示时,父窗口最小化

c++ - ListView控件中的LVN_ITEMCHANGED优化

c++ - 重定向的标准输入管道被创建的子进程忽略

python multiprocessing.Pool kill *特定*长时间运行或挂起的进程