dev*_*os1 21 .net c# file windows-explorer
这可以是在与文件/文件夹一起使用的程序中具有的便利功能.使用以下方法实际打开包含文件夹很容易:
System.Diagnostics.Process.Start( *path to folder* );
Run Code Online (Sandbox Code Playgroud)
...但是如何在该父文件夹中实际选择目标文件?如果我使用Process.Start方法,它实际上会尝试打开该文件.
Reg*_*ent 50
根据Windows资源管理器命令行选项,您只需要explorer
使用/select
参数启动进程.
例如,' explorer /select,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));
Run Code Online (Sandbox Code Playgroud)