visual-studiovisual-studio-extensionsenvdte

Open a file in solution explorer with a relative path by a shortcut key


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.


Solution

  • 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);
    }