Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implement "Open Containing Folder" and highlight file

Tags:

This can be a handy functionality to have in a program that works with files/folders. It's easy enough to actually open the containing folder using:

System.Diagnostics.Process.Start( *path to folder* ); 

...but how do I go about actually selecting the target file within that parent folder? If I use the Process.Start method it actually attempts to open the file.

like image 920
devios1 Avatar asked May 13 '10 19:05

devios1


People also ask

What is Open containing folder?

Just Open Containing Folder command is available on right click in the Solution Explorer. It lets you quickly open the containing folder of the selected item.

Can you highlight a file in a folder?

Right-click the file, folder, or link that you want to highlight, and then select Pin to top. Note: You can highlight a maximum of 3 items per library, folder, or view.


1 Answers

According to Windows Explorer Command-Line Options you just need to start an explorer process with /select parameter.

For instance, 'explorer /select,c:\Windows' will open a window with c:\windows folder selected.

So simply Process.Start("explorer.exe", "/select," + filename) should be enough.

like image 152
Regent Avatar answered Sep 22 '22 22:09

Regent