0

Is there a way to select/open a file from the solution explorer with a shortcut key?

In all my projects I have a file named Note.txt, it can be found in Project\Info\Note.txt.

Want to assign a shortcut that when we hit it, it select and open the Note.txt of the current project.

Using 3rd party tools are welcome.


If I know how to write the macro, etc with a tool, then we can set a shortcut for it.

Kasrak
  • 1,509
  • 4
  • 24
  • 48

1 Answers1

1

You can use the following command with my Visual Commander extension:

public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package) 
{
    string projectFile = DTE.ActiveDocument.ProjectItem.ContainingProject.FileName;
    string notePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(projectFile), @"Info\Note.txt");
    DTE.ItemOperations.OpenFile(notePath);
}
Sergey Vlasov
  • 26,641
  • 3
  • 64
  • 66
  • Nice, Thanks Mr. Sergey Vlasov, It doesn't select the file in the Solution Explorer, but will open it. It helped. – Kasrak Jul 11 '21 at 08:53