打开文件夹并使用WPF突出显示特定文件 [英] Open a folder and highlight a particular file with WPF

查看:102
本文介绍了打开文件夹并使用WPF突出显示特定文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用WPF启动资源管理器窗口并突出显示该文件夹中的文件?我已经尝试了以下方法:

Is there a way to launch an Explorer window and highlight a file in that folder with WPF ? I've already tried the following :

Process ExplorerWindowProcess = new Process();

ExplorerWindowProcess.StartInfo.FileName = "explorer.exe";
ExplorerWindowProcess.StartInfo.Arguments = ConfigFile.File.FullName;

ExplorerWindowProcess.Start();

...但是这会使用Windows资源管理器中的默认应用程序打开文件(在我的情况下为XML文件),我非常不希望这样做.我知道,可用于Eclipse的Aptana工具使您能够完全根据需要在Eclipse项目浏览器中选择一个文件,并在资源管理器中显示该文件,但是我需要一种在WPF应用程序中实现此功能的方法.

... but that opens the file (in my case an XML file) with the default application in Windows Explorer, which I very much don't want. I know that the Aptana tools available for Eclipse allow you the ability to select a file in the Eclipse project browser and show the file in Explorer exactly as I want, but I need a way to implement this in my WPF app.

推荐答案

Explorer命令行参数
http://support.microsoft.com/kb/152457

Explorer Command Line Arguments
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突出显示特定文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆