实现“打开包含文件夹”并突出显示文件
这可以是在与文件/文件夹一起使用的程序中具有的便利function。 使用以下方法实际打开包含文件夹很容易:
System.Diagnostics.Process.Start( *path to folder* );
…但是如何在该父文件夹中实际选择目标文件? 如果我使用Process.Start方法,它实际上会尝试打开该文件。
根据Windows资源管理器命令行选项,您只需使用/select
参数启动explorer
进程。
例如,’ explorer /select,c:\Windows
‘将打开一个选中了c:\windows
文件夹的c:\windows
。
所以简单的Process.Start("explorer.exe", "/select," + filename)
应该足够了。
使用/select, "filename"
命令行参数执行Explorer.exe
System.Diagnostics.Process.Start( "explorer.exe", string.Format("/select, \"{0}\"", filename));
包含文件夹,Self目录以多种方式表示! 简单的2种方式.
而且, .\.
不知道有什么区别!..:D从DOS和bat文件… Start .
或者Start .\.
(Y)
尝试……这两个工作,但检查这是否是你期望的解决方案!
System.Diagnostics.Process.Start("explorer.exe", @".\.");
要么
System.Diagnostics.Process.Start("explorer.exe", @".");
–
- 有时应用程序是从临时目录或不同的目录运行的(例如:在Sandbox中……或者在被防病毒软件扫描时等等:)